Documentation ¶
Index ¶
- Constants
- func Marshal(msg *Msg) ([]byte, error)
- func ReadMsgLen(buf []byte) (uint16, error)
- type Client
- type ClientMngr
- func (owner *ClientMngr) AddUID(id int32, uid uint64)
- func (owner *ClientMngr) CheckConnection(id int32) error
- func (owner *ClientMngr) DelUID(id int32)
- func (owner *ClientMngr) GetUIDByConnection(id int32) uint64
- func (owner *ClientMngr) RefreshHBTime(id int32)
- func (owner *ClientMngr) SendToAll(msg *Msg)
- func (owner *ClientMngr) SendToClient(id int32, msg *Msg)
- type Config
- type ConnEventCallback
- type Event
- type IHandler
- type Msg
- type Router
- type Service
Constants ¶
View Source
const ( // MsgLenMax int = 4096 // 单条消息长度限制.(暂不做硬性限制, 逻辑层控制.) MsgHeadLen int = 8 // 消息头长度. MsgLenIndexE int = 2 // 消息长度信息在消息头[]byte中的索引结束位置.起始位置固定为0 MsgCryptFlagIndex int = 2 // 消息加密标识在消息头[]byte中的索引. MsgZipFlagIndex int = 3 // 消息压缩标识在消息头[]byte中的索引. MsgMsgIDIndexS int = 4 // 消息ID在消息头[]byte中的索引起始位置. MsgMsgIDIndexE int = 8 // 消息ID在消息头[]byte中的索引结束位置. )
消息结构相关常量.
View Source
const ( MsgCryptFlag byte = 1 // 消息加密标识符. MsgZipFlag byte = 1 // 消息压缩标识符. )
加密, 压缩标识.
View Source
const BufReadMax int = 1024
BufReadMax 单次接收消息长度.
View Source
const HeartBeatTimeTick int64 = 300
HeartBeatTimeTick 心跳检测频率.(单位:秒)
View Source
const MsgChanMax int32 = 100
MsgChanMax message channel size.
Variables ¶
This section is empty.
Functions ¶
func ReadMsgLen ¶
ReadMsgLen 获得消息长度. 参数: 1-长度为2字节的消息头信息. 返回: 1-消息长度, 2-错误信息.
Types ¶
type ClientMngr ¶
ClientMngr struct.
func (*ClientMngr) AddUID ¶
func (owner *ClientMngr) AddUID(id int32, uid uint64)
AddUID add hashUIDs data. (login verify success, logic call this function.)
func (*ClientMngr) CheckConnection ¶
func (owner *ClientMngr) CheckConnection(id int32) error
CheckConnection function.
func (*ClientMngr) DelUID ¶
func (owner *ClientMngr) DelUID(id int32)
DelUID del hashUIDs data. (logic call this function.)
func (*ClientMngr) GetUIDByConnection ¶
func (owner *ClientMngr) GetUIDByConnection(id int32) uint64
GetUIDByConnection function.
func (*ClientMngr) RefreshHBTime ¶
func (owner *ClientMngr) RefreshHBTime(id int32)
RefreshHBTime function.
func (*ClientMngr) SendToClient ¶
func (owner *ClientMngr) SendToClient(id int32, msg *Msg)
SendToClient function.
type ConnEventCallback ¶
ConnEventCallback type callback
type Router ¶
Router struct.
func (*Router) RegHandler ¶
RegHandler 注册消息处理函数. 参数: 1-消息ID, 2-消息处理器结构体实例.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service struct.
func (*Service) GetClientMngr ¶
func (owner *Service) GetClientMngr() *ClientMngr
GetClientMngr get TcpConnMngr Instance.
func (*Service) RegHandler ¶
RegHandler register net message handler.
func (*Service) SetConnCallback ¶
func (owner *Service) SetConnCallback(cbAdd, cbDel ConnEventCallback)
SetConnCallback register connection close event callback.
Click to show internal directories.
Click to hide internal directories.