Versions in this module Expand all Collapse all v0 v0.1.0 Aug 3, 2021 Changes in this version + var MaxMsgLen = uint16(10 * 1024) + var MinMsgLen = uint16(2) + var TCP_TIMEOUT = 20 + func GetProtobufPayload(data []byte) (uint16, proto.Message, error) + func ParseProtobuf(msgName protoreflect.FullName, data []byte) (proto.Message, error) + func PutProtobufPayload(msgID uint16, msg proto.Message) ([]byte, error) + func RegisterPayload(msgID uint16, msgName protoreflect.FullName) error + type Cipher interface + Decrypt func(data []byte) []byte + Encrypt func(data []byte) []byte + type DefTcpProcessor struct + MsgHandles map[uint16]MsgHander + func (slf *DefTcpProcessor) HandleRecvMsg(session *Session, msgData []byte) + func (slf *DefTcpProcessor) RegisterMsg(msgID uint16, name protoreflect.FullName, handle HandleFunc) + type HandleFunc func(session *Session, msg proto.Message) + type MsgHander struct + type MsgParser struct + func NewMsgParser(cipher Cipher) *MsgParser + func (slf *MsgParser) Read(conn net.Conn) ([]byte, error) + func (slf *MsgParser) Write(conn net.Conn, msgData []byte) error + type PingPongFunc func(session *Session) + type Rc4Cipher struct + func NewRc4Cipher(key []byte) *Rc4Cipher + func (slf *Rc4Cipher) Decrypt(data []byte) []byte + func (slf *Rc4Cipher) Encrypt(data []byte) []byte + type Session struct + Writable bool + func (slf *Session) Close() + func (slf *Session) GetActiveTime() int64 + func (slf *Session) GetID() uint32 + func (slf *Session) LocalAddr() net.Addr + func (slf *Session) RemoteAddr() net.Addr + func (slf *Session) SetCipher(recv, send Cipher) + func (slf *Session) SetPingPong(pingpong PingPongFunc, interval uint32) + func (slf *Session) SetWritable(bWrite bool) + func (slf *Session) Start() + func (slf *Session) SyncWriteMsg(msg []byte) error + func (slf *Session) WriteMsg(msg []byte) error + type TCPClient struct + AutoReconnect bool + DstAddr string + HeartbeatExpire int64 + PendingWriteNum uint16 + Pingpong PingPongFunc + PingpongInterval uint32 + func NewTCPClient(dstAddr string, h TcpProcessor) *TCPClient + func (slf *TCPClient) Close() + func (slf *TCPClient) Start() + func (slf *TCPClient) SyncWriteMsg(msg []byte) error + func (slf *TCPClient) WriteMsg(msg []byte) error + type TcpProcessor interface + HandleRecvMsg func(session *Session, msg []byte) + OnConnectClose func(session *Session) + OnConnectSucc func(session *Session)