Documentation ¶
Index ¶
- type Client
- type EventConnServer
- type EventDisConnClient
- type EventDisConnServer
- type EventPacketClient
- type EventPacketServer
- type OnEventConnServerFunc
- type OnEventDefaultFunc
- type OnEventDisConnClientFunc
- type OnEventDisConnServerFunc
- type OnEventPacketClientFunc
- type OnEventPacketServerFunc
- type OnParseProtoHeadFunc
- type Remote
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { OnEventPacket OnEventPacketClientFunc OnEventDisConn OnEventDisConnClientFunc Remote Remote // contains filtered or unexported fields }
己方作为客户端
func (*Client) Connect ¶
func (p *Client) Connect(address string, recvPacketMaxLen uint32, tcpChan chan<- interface{}, OnEventDisConn OnEventDisConnClientFunc, OnEventPacket OnEventPacketClientFunc, onParseProtoHead OnParseProtoHeadFunc, sendChanCapacity uint32) (err error)
连接 每个连接有一个 发送协程, 一个 接收协程 事件放入 参数 eventChan 中, 以供外部处理 recvPacketMaxLen:接受数据包的最大长度(包头+包体) tcpChan:外部传递的事件处理管道.连接的事件会放入该管道,以供外部处理 sendChanCapacity:发送管道容量
type EventConnServer ¶
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// server 链接成功事件
type EventPacketClient ¶
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// client 数据包事件
type EventPacketServer ¶
数据包事件
type OnEventDefaultFunc ¶
type OnEventDefaultFunc func(v interface{}) int
type OnEventPacketClientFunc ¶
处理数据包事件
type OnEventPacketServerFunc ¶
处理数据包事件
type OnParseProtoHeadFunc ¶
解析协议包头 返回长度:完整包总长度 返回0:不是完整包 返回-1:包错误
type Server ¶
type Server struct { OnConn OnEventConnServerFunc OnPacket OnEventPacketServerFunc OnDisconn OnEventDisConnServerFunc // contains filtered or unexported fields }
func (*Server) Strat ¶
func (p *Server) Strat(address string, recvPacketMaxLen uint32, eventChan chan<- interface{}, onConn OnEventConnServerFunc, onDisconn OnEventDisConnServerFunc, onPacket OnEventPacketServerFunc, onParseProtoHead OnParseProtoHeadFunc, sendChanCapacity uint32) (err error)
运行服务 rwBuffLen:tcp recv/send 缓冲大小 recvPacketMaxLen:最大包长(包头+包体) eventChan:外部传递的事件处理
Click to show internal directories.
Click to hide internal directories.