Documentation ¶
Index ¶
Constants ¶
View Source
const CheckNull = "CheckNull"
View Source
const RandomNum = 5
Variables ¶
This section is empty.
Functions ¶
func RandStringBytesMaskImperSrc ¶
RandStringBytesMaskImperSrc 生成随机字符串
Types ¶
type IAdmin ¶
type IAdmin interface { SendMsg(funcName string) func(c *gin.Context) HandlerWS(string, *websocket.AcceptOptions) func(c *gin.Context) }
IAdmin 接口
type IClient ¶
type IClient interface { // SendMes 发送消息 非阻塞 失败返回 SendMes(msg IMessage) bool // MsgChan 返回一个可收取的channel 用于接收消息 MsgChan() <-chan IMessage // GetCtx 返回context.Context GetCtx() context.Context // SetCtx 设置context SetCtx(context.Context) // Shutdown 回收资源 // 多次调用无副作用! Shutdown() }
IClient 客户端接口
type IHandle ¶
type IHandle interface { Register(int32, TypeHandlerFunc) bool GetHandler(int32) (TypeHandlerFunc, bool) }
IHandle 注册对应type处理函数
type IManage ¶
type IManage interface { // Register 注册接口 Register(key string) IClient // UnRegister 注销接口 UnRegister(key string) // FindClient 查找在线客户端 FindClient(key string) (IClient, bool) // FindClients 批量查找在线客户端 FindClients(key ...string) []IClient // GetAll 查找所有客户端 GetAll() []IClient }
IManage 只提供用户管理存储
type IMessage ¶
type IMessage interface { Marshal() ([]byte, error) Unmarshal(data []byte) error GetType() int32 GetTo() string }
IMessage 定义消息接口
type ITopic ¶
type ITopic interface { // CreateTopic 创建topic CreateTopic(string) // DeleteTopic 删除topic DeleteTopic(string) // Subscribe 订阅 Subscribe(topic, key string) bool // UnSubscribe 退订 UnSubscribe(topic, key string) bool // GetTopicList 获取订阅topic的用户 GetTopicList(topic string) []string }
ITopic 订阅表
Click to show internal directories.
Click to hide internal directories.