Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Config ¶
type Config struct {
Tick bool // 是否开启定时器
Addr string // ws服务地址
ReadTimeout time.Duration // 读超时
WriteTimeout time.Duration // 写超时
MaxMsgSize int // 消息体最大长度
MinMsgSize int // 消息体最小长度
MaxConns int // 最大连接数
ReadBufferSize int // 读缓冲区大小
WriteBufferSize int // 写缓冲区大小
CertFile string // 证书路径
KeyFile string // 证书密钥路径
}
Config websocket服务配置
type Handler ¶
type Handler interface {
// OnMessage 消息处理
OnMessage(conn Conn, message []byte)
// OnConnect 连接建立时调用
OnConnect(conn Conn)
// OnClose 连接关闭时调用
OnClose(conn Conn)
// OnPing 收到PingMessage时调用
OnPing(conn Conn, pingMessage string)
// OnTick 定时任务, bool值返回true的话定时器将被终止, 并不可恢复
OnTick() (time.Duration, bool)
// GenerateID 生成全局唯一ID
GenerateID() int64
}
Click to show internal directories.
Click to hide internal directories.