Documentation
¶
Index ¶
- type Client
- type TcpCfg
- type TcpModule
- func (tm *TcpModule) Close(clientId string)
- func (tm *TcpModule) GetClientIp(clientId string) string
- func (tm *TcpModule) GetConnNum() int
- func (tm *TcpModule) GetProcessor() processor.IRawProcessor
- func (tm *TcpModule) Init(tcpCfg *TcpCfg, process processor.IRawProcessor)
- func (tm *TcpModule) NewClient(conn network.Conn) network.Agent
- func (tm *TcpModule) OnInit() error
- func (tm *TcpModule) SendMsg(clientId string, msg interface{}) error
- func (tm *TcpModule) SendRawMsg(clientId string, msg []byte) error
- func (tm *TcpModule) Start() error
- type TcpPack
- type TcpPackType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TcpCfg ¶
type TcpCfg struct {
ListenAddr string //监听地址
MaxConnNum int //最大连接数
PendingWriteNum int //写channel最大消息数量
LittleEndian bool //是否小端序
LenMsgLen int //消息头占用byte数量,只能是1byte,2byte,4byte。如果是4byte,意味着消息最大可以是math.MaxUint32(4GB)
MinMsgLen uint32 //最小消息长度
MaxMsgLen uint32 //最大消息长度,超过判定不合法,断开连接
ReadDeadlineSecond time.Duration //读超时
WriteDeadlineSecond time.Duration //写超时
}
type TcpModule ¶
func (*TcpModule) GetClientIp ¶
func (*TcpModule) GetConnNum ¶
func (*TcpModule) GetProcessor ¶
func (tm *TcpModule) GetProcessor() processor.IRawProcessor
type TcpPack ¶
type TcpPack struct {
Type TcpPackType //0表示连接 1表示断开 2表示数据
ClientId string
Data interface{}
RecyclerReaderBytes func(data []byte)
}
type TcpPackType ¶
type TcpPackType int8
const ( TPTConnected TcpPackType = 0 TPTDisConnected TcpPackType = 1 TPTPack TcpPackType = 2 TPTUnknownPack TcpPackType = 3 )
Click to show internal directories.
Click to hide internal directories.