Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRouter ¶
type BaseRouter struct{}
BaseRouter 用于重写, 这样就不需要写出所有方法
func (*BaseRouter) OnConnected ¶
func (b *BaseRouter) OnConnected(c *Client)
func (*BaseRouter) OnDisconnect ¶
func (b *BaseRouter) OnDisconnect(c *Client)
func (*BaseRouter) OnMessage ¶
func (b *BaseRouter) OnMessage(c *Client, message []byte)
func (*BaseRouter) OnServerClose ¶
func (b *BaseRouter) OnServerClose()
func (*BaseRouter) OnServerUpdate ¶
func (b *BaseRouter) OnServerUpdate()
type Client ¶
type Client struct { Server *Server //server对线 User interface{} //用户对象 UserData sync.Map //保存一些用户自定义内容 ConnectionIndex int // LastMsgTime time.Time //最后收到消息时间 Ip string //登录IP WsMessageType int //websocket的协议类型,1:text, 2:binary // contains filtered or unexported fields }
Client 保存客户端连接和用户
type IRouter ¶
type IRouter interface { OnMessage(c *Client, message []byte) // OnMessage 用户协程中调用 OnDisconnect(c *Client) // OnDisconnect hub协成中调用 OnServerClose() // 关闭服务器执行一次 OnServerUpdate() OnConnected(c *Client) }
IRouter 方法2: 接口
Click to show internal directories.
Click to hide internal directories.