Documentation
¶
Index ¶
- Constants
- Variables
- func AsWebSocket(handler func(*Conn) error) httpx.RespOption
- func AsWebSocketWithPing(handler func(*Conn) error) httpx.RespOption
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) IsClosed() bool
- func (c *Conn) Messages() <-chan *Message
- func (c *Conn) Send(msg *Message) error
- func (c *Conn) SendError(errMsg string) error
- func (c *Conn) SendEvent(eventType string, data interface{}) error
- func (c *Conn) SendJSON(data interface{}) error
- type Message
Constants ¶
View Source
const BufSize = 1024
Variables ¶
View Source
var ErrClosed = errors.New("websocket connection closed")
Functions ¶
func AsWebSocket ¶
func AsWebSocket(handler func(*Conn) error) httpx.RespOption
AsWebSocket 设置为 WebSocket 连接
func AsWebSocketWithPing ¶
func AsWebSocketWithPing(handler func(*Conn) error) httpx.RespOption
AsWebSocketWithPing 带 Ping 的 WebSocket
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a WebSocket connection wrapper.
Click to show internal directories.
Click to hide internal directories.