Documentation
¶
Index ¶
- Constants
- Variables
- func AddSession(s *Session)
- func Bind(name string, h Handler, args any, opt ...bindOptionFunc)
- func BindFunc(h Handler, args any, opt ...bindOptionFunc)
- func CountSession() int
- func Encode(name string, i any) ([]byte, error)
- func EncodePackage(pkg *Package) ([]byte, error)
- func Forward(name string, msgId string, i any)
- 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 any) ([]byte, error)
- func RequestServerAddr(name string) (string, error)
- func Route(serverId, msgId string, i any)
- func RunOnce()
- func WithPrivate() bindOptionFunc
- func WithServer(name string) bindOptionFunc
- func WithoutQueue() bindOptionFunc
- 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 ¶
func AddSession(s *Session)
func CountSession ¶
func CountSession() int
func EncodePackage ¶
func ListenAndServe ¶
func RemoveSession ¶
func RemoveSession(id string)
func WithPrivate ¶
func WithPrivate() bindOptionFunc
func WithServer ¶
func WithServer(name string) bindOptionFunc
func WithoutQueue ¶
func WithoutQueue() bindOptionFunc
Types ¶
type Context ¶
type Package ¶
type Package struct {
Id string `json:"id,omitempty"` // 消息ID
Data json.RawMessage `json:"data,omitempty"` // 数据,object类型
Sign string `json:"sign,omitempty"` // 签名
Ssid string `json:"ssid,omitempty"` // 会话ID
Version int `json:"version,omitempty"` // 版本
Ts int64 `json:"ts,omitempty"` // 过期时间戳
ServerName string `json:"serverName,omitempty"` // 请求的协议头
ClientAddr string `json:"clientAddr,omitempty"` // 客户端地址
Body any `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.