Documentation ¶
Index ¶
Constants ¶
View Source
const ( MsgTypeReq int32 = 1 MsgTypeAck int32 = 2 MsgTypeNtf int32 = 3 MsgTypeCmd int32 = 4 )
View Source
const ( MsgIdConnDisconnect = -1 MsgIdConnConnect = -2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Send(msgId MessageId, body MessageBody) error Close() Reconnect() // contains filtered or unexported methods }
客户端接口
type Conn ¶
type Conn interface { Send(msgId MessageId, body MessageBody) error Close() Address() string NetProtocol() Protocol Identity() uint32 State() ConnState // contains filtered or unexported methods }
网络连接接口
type MessageBody ¶
type MessageBody []byte
消息体
func (MessageBody) Len ¶
func (i MessageBody) Len() int
type MessageId ¶
type MessageId int32
消息ID *
消息ID组成: 123456 1 表示消息类别REQ、ACK、NTF、CMD 2 表示消息组,例如gate, hall, game 34 在game消息组中表示游戏ID,其他消息组暂时为0 56 表示具体消息
type MessagePacker ¶
type MessagePacker interface { // 封包,传入消息ID和包体,返回字节集 Pack(MessageId, MessageBody) []byte // 解包,传入符合包结构的字节集,返回消息ID,包体,剩余内容 Unpack([]byte) (MessageId, MessageBody, []byte) }
消息封装器接口
Click to show internal directories.
Click to hide internal directories.