Documentation
¶
Index ¶
Constants ¶
View Source
const ( // 文本消息 TextMessage = 1 // 二进制数据消息 BinaryMessage = 2 )
Variables ¶
View Source
var EmptyLogger = &l{}
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
MsgType int // 消息类型 TextMessage | BinaryMessage
ReadBufferSize int // 读取缓存大小
WriteBufferSize int // 写入缓存大小
CheckOrigin func(*http.Request) bool // 检查跨域来源是否允许建立连接
Logger LoggerI // 用于打印内部产生日志
}
Config 配置项
type Conn ¶
type Conn struct {
Socket *websocket.Conn // 连接
ID uint64
// contains filtered or unexported fields
}
Conn 连接实例
type EventHandle ¶ added in v1.2.16
type EventHandle func(*Conn)
type Message ¶
type Message struct {
SID uint64
Payload []byte
Socket *Conn
MsgType int
// contains filtered or unexported fields
}
Message ws 接收到的消息
type WS ¶
type WS struct {
Clients map[uint64]*Conn
Upgrader *websocket.Upgrader
MsgType int
// contains filtered or unexported fields
}
WS ws 连接
func (*WS) HTTPHandler ¶
func (ws *WS) HTTPHandler(w http.ResponseWriter, r *http.Request)
HTTPHandler 给 http 控制器绑定使用
func (*WS) HandleClose ¶ added in v1.2.16
func (ws *WS) HandleClose(fn EventHandle)
func (*WS) HandleCreate ¶ added in v1.2.16
func (ws *WS) HandleCreate(fn EventHandle)
func (*WS) Playground ¶
func (ws *WS) Playground(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.