Documentation
¶
Index ¶
- Constants
- Variables
- func NewRouter() rt.Router
- func WithNNetClientEvents(onReady OnReadyFunc, packer packet.Packer) nnet.RunOption
- func WithNNetClientProtocol(onReady OnReadyFunc) []nnet.RunOption
- func WithNNetProtocol(config Config) []nnet.RunOption
- type Config
- type HandshakeAckPayloadFunc
- type HandshakeReq
- type HandshakeResp
- type HandshakeValidatorFunc
- type Header
- type Match
- type MessageHeader
- type MsgType
- type OnReadyFunc
- type Packer
- type Packet
- type RouteMap
- type Type
Constants ¶
View Source
const ( // Unknown 未知包类型,无意义 Unknown Type = iota // Handshake 握手数据(服务端主动发起) Handshake = 0x01 // HandshakeAck 握手回复(客户端回复) HandshakeAck = 0x02 // Heartbeat 心跳(服务端发起) Heartbeat = 0x03 // Data 数据传输 Data = 0x04 // Kick 服务端主动断开连接 Kick = 0x05 )
View Source
const ( Request MsgType = 0x00 Notify = 0x01 Response = 0x02 Push = 0x03 )
Message types
Variables ¶
Functions ¶
func WithNNetClientEvents ¶ added in v1.1.4
func WithNNetClientEvents(onReady OnReadyFunc, packer packet.Packer) nnet.RunOption
func WithNNetClientProtocol ¶
func WithNNetClientProtocol(onReady OnReadyFunc) []nnet.RunOption
func WithNNetProtocol ¶
Types ¶
type Config ¶
type Config struct { HeartbeatInterval time.Duration HandshakeValidator HandshakeValidatorFunc }
type HandshakeAckPayloadFunc ¶
type HandshakeAckPayloadFunc func() any
type HandshakeReq ¶
type HandshakeReq struct { Version string `json:"version"` // 客户端版本,服务器以此判断是否合适与客户端通信 Type string `json:"type"` // 客户端类型,与客户端版本号一起来确定客户端是否合适 ClientId string `json:"clientId"` // 客户端ID,服务器以此取值 ClientSecret string `json:"clientSecret"` // 客户端密钥,服务器以此判定客户端是否可用 // 透传信息 Payload any `json:"payload,optional,omitempty"` }
type HandshakeResp ¶
type HandshakeValidatorFunc ¶
type HandshakeValidatorFunc func(*HandshakeReq) error
type Header ¶
type Header struct { PacketType Type // 数据帧 类型 Length uint32 // 数据长度 MessageHeader // 消息头 }
type MessageHeader ¶
type OnReadyFunc ¶
type OnReadyFunc func()
Click to show internal directories.
Click to hide internal directories.