Versions in this module Expand all Collapse all v1 v1.0.6 Sep 19, 2024 Changes in this version type Request + func (r *Request) GetExtendData() []byte + func (r *Request) GetHeaderData() []byte + func (r *Request) GetMagicCode() uint16 + func (r *Request) GetMessage() ziface.IMessage v1.0.5 Sep 19, 2024 Changes in this version type Connection + func (c *Connection) SendBuffMsgPackage(msgPackage ziface.IMessage) ([]byte, error) + func (c *Connection) SendMsgPackage(msgPackage ziface.IMessage) ([]byte, error) type Message + HeaderData []byte + func (msg *Message) GetHeaderData() []byte + func (msg *Message) SetHeaderData(data []byte) v1.0.4 Sep 18, 2024 v1.0.3 Sep 18, 2024 Changes in this version type Message + ExtendData []byte + func (msg *Message) GetExtendData() []byte + func (msg *Message) GetMagicCode() uint16 + func (msg *Message) SetExtendData(extendData []byte) error + func (msg *Message) SetMagicCode(magicCode uint16) v1.0.2 Nov 9, 2022 Changes in this version + func GetLogger() ziface.ILogger + func LoadZapLogger(level LogLevel) ziface.ILogger + func NewDataPack() ziface.Packet + func NewServer(opts ...Option) ziface.IServer + func SetLogger(logHandler ziface.ILogger, level LogLevel) + type BaseRouter struct + func (br *BaseRouter) Handle(req ziface.IRequest) + func (br *BaseRouter) PostHandle(req ziface.IRequest) + func (br *BaseRouter) PreHandle(req ziface.IRequest) + type ConnManager struct + func NewConnManager() *ConnManager + func (connMgr *ConnManager) Add(conn ziface.IConnection) + func (connMgr *ConnManager) ClearConn() + func (connMgr *ConnManager) ClearOneConn(connID uint32) + func (connMgr *ConnManager) Get(connID uint32) (ziface.IConnection, error) + func (connMgr *ConnManager) Len() int + func (connMgr *ConnManager) Remove(conn ziface.IConnection) + type Connection struct + Conn *net.TCPConn + ConnID uint32 + MsgHandler ziface.IMsgHandle + TCPServer ziface.IServer + func NewConnection(server ziface.IServer, conn *net.TCPConn, connID uint32, ...) *Connection + func (c *Connection) Context() context.Context + func (c *Connection) GetConnID() uint32 + func (c *Connection) GetProperty(key string) (interface{}, error) + func (c *Connection) GetTCPConnection() *net.TCPConn + func (c *Connection) RemoteAddr() net.Addr + func (c *Connection) RemoveProperty(key string) + func (c *Connection) SendBuffMsg(msgID, sn uint8, data []byte) error + func (c *Connection) SendMsg(msgID, sn uint8, data []byte) error + func (c *Connection) SetProperty(key string, value interface{}) + func (c *Connection) Start() + func (c *Connection) StartReader() + func (c *Connection) StartWriter() + func (c *Connection) Stop() + type DataPack struct + func (dp *DataPack) GenerateSn() uint8 + func (dp *DataPack) GetHeadLen() uint16 + func (dp *DataPack) Pack(msg ziface.IMessage) ([]byte, error) + func (dp *DataPack) Unpack(binaryData []byte) (ziface.IMessage, error) + type LogLevel uint8 + type Message struct + Data []byte + DataLen uint16 + ID uint8 + MagicCode uint16 + Sn uint8 + func NewMsgPackage(ID, Sn uint8, data []byte) *Message + func (msg *Message) GetData() []byte + func (msg *Message) GetDataLen() uint16 + func (msg *Message) GetMsgID() uint8 + func (msg *Message) GetSn() uint8 + func (msg *Message) SetData(data []byte) + func (msg *Message) SetDataLen(len uint16) + func (msg *Message) SetMsgID(msgID uint8) + type MsgHandle struct + Apis map[uint8]ziface.IRouter + TaskQueue []chan ziface.IRequest + WorkerPoolSize uint32 + func NewMsgHandle() *MsgHandle + func (mh *MsgHandle) AddRouter(msgID uint8, router ziface.IRouter) + func (mh *MsgHandle) DoMsgHandler(request ziface.IRequest) + func (mh *MsgHandle) SendMsgToTaskQueue(request ziface.IRequest) + func (mh *MsgHandle) StartOneWorker(workerID int, taskQueue chan ziface.IRequest) + func (mh *MsgHandle) StartWorkerPool() + type Option func(s *Server) + func WithLogger(logger ziface.ILogger) Option + func WithPacket(pack ziface.Packet) Option + type Request struct + func (r *Request) GetConnection() ziface.IConnection + func (r *Request) GetData() []byte + func (r *Request) GetMsgID() uint8 + func (r *Request) GetSn() uint8 + type Server struct + ConnMgr ziface.IConnManager + IP string + IPVersion string + Name string + OnConnStart func(conn ziface.IConnection) + OnConnStop func(conn ziface.IConnection) + Port int + func (s *Server) AddRouter(msgID uint8, router ziface.IRouter) + func (s *Server) CallOnConnStart(conn ziface.IConnection) + func (s *Server) CallOnConnStop(conn ziface.IConnection) + func (s *Server) GetConnMgr() ziface.IConnManager + func (s *Server) Packet() ziface.Packet + func (s *Server) Serve() + func (s *Server) SetOnConnStart(hookFunc func(ziface.IConnection)) + func (s *Server) SetOnConnStop(hookFunc func(ziface.IConnection)) + func (s *Server) Start() + func (s *Server) Stop()