Documentation ¶
Index ¶
- Constants
- Variables
- func AddSession(s *Session)
- func Bind(h Handler, args interface{})
- func BindWithName(name string, h Handler, args interface{})
- func BindWithoutQueue(name string, h Handler, args interface{})
- func CountSession() int
- func Encode(name string, i interface{}) ([]byte, error)
- func EncodePackage(pkg *Package) ([]byte, error)
- func Forward(name string, msgId string, i interface{})
- func Handle(ctx *Context, name string, data []byte) error
- func Hook(h Handler)
- func ListenAndServe(addr string) error
- func RegisterService(conf *ServiceConfig)
- func RemoveSession(id string)
- func Request(serverName, msgId string, in interface{}) ([]byte, error)
- func RequestServerAddr(name string) (string, error)
- func Route(serverId, msgId string, i interface{})
- func RunOnce()
- type Client
- type CmdSet
- type Conn
- type Context
- type Handler
- type M
- type Package
- type ServeConn
- type Server
- type ServiceConfig
- type Session
- type TCPConn
Constants ¶
View Source
const ( RawMessage = 0x01 PingMessage = 0xf1 PongMessage = 0xf2 )
Variables ¶
View Source
var (
ErrInvalidSign = errors.New("invalid sign")
)
Functions ¶
func AddSession ¶ added in v1.6.20210427
func AddSession(s *Session)
func BindWithName ¶
绑定 注:客户端发送的消息ID仅允许包含字母、数字
func BindWithoutQueue ¶ added in v1.6.20210429
绑定。消息不入队列直接处理 注:客户端发送的消息ID仅允许包含字母、数字
func CountSession ¶ added in v1.7.20210716
func CountSession() int
func EncodePackage ¶ added in v1.8.20210922
func ListenAndServe ¶
func RemoveSession ¶ added in v1.6.20210427
func RemoveSession(id string)
Types ¶
type CmdSet ¶
type CmdSet struct {
// contains filtered or unexported fields
}
type Context ¶
type Package ¶
type Package struct { Id string `json:",omitempty"` // 消息ID Data json.RawMessage `json:",omitempty"` // 数据,object类型 Sign string `json:",omitempty"` // 签名 Ssid string `json:",omitempty"` // 会话ID Version int `json:"Ver,omitempty"` // 版本 Ts int64 `json:",omitempty"` // 过期时间戳 ServerName string `json:",omitempty"` // 请求的协议头 ClientAddr string `json:",omitempty"` // 客户端地址 Body interface{} `json:"-"` // 解析成Data }
type ServiceConfig ¶
type TCPConn ¶
type TCPConn struct {
// contains filtered or unexported fields
}
func (*TCPConn) RemoteAddr ¶
Click to show internal directories.
Click to hide internal directories.