Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConnectionClosed 连接已关闭 ErrConnectionClosed = errors.New("connection closed") // ErrUnsupportProtocol 协议不支持 ErrUnsupportProtocol = errors.New("unsupport protocol") // ErrInvalidParameter 非法参数 ErrInvalidParameter = errors.New("invalid parameter") // ErrKnownApp 不认识的App ErrKnownApp = errors.New("known application") // ErrAuthFailed 认证失败 ErrAuthFailed = errors.New("auth failed") // ErrNeedAuth 需要认证 ErrNeedAuth = errors.New("need auth") // ErrNoMoreMessage 没有消息 ErrNoMoreMessage = errors.New("no more message") )
Functions ¶
func ConnectionID ¶
ConnectionID 通过AppID和UserID组合成ConnectionID
Types ¶
type Connection ¶
type Connection interface { ID() string AppID() string UserID() string DeviceID() string LoginSuccess(appid, userid, device, version string) IsLogin() bool Close(force bool) error String() string Send(cmd *protocol.Command) error }
Connection 连接接口
type Server ¶
type Server interface { // Run 运行 Run(context.Context) error // Close 关闭 Close(timeout time.Duration) (err error) }
Server 服务接口
type ServerHandler ¶
type ServerHandler interface { // OnNewConnection 当有新连接建立 OnNewConnection(conn Connection) // OnCloseConnection 当有连接关闭 OnCloseConnection(conn Connection) // OnReceivedCommand 当收到命令 OnReceivedCommand(conn Connection, command *protocol.Command) error }
ServerHandler 服务回调接口
Click to show internal directories.
Click to hide internal directories.