Versions in this module Expand all Collapse all v1 v1.1.0 Dec 9, 2020 Changes in this version + func NewConnManager() netConn.IConnManager + func NewConnection(server *Service, conn net.Conn, connId uint64, msgHandler netConn.IMsgHandle, ...) netConn.IConnection + func NewMsgHandle(workerSize int, taskQueueSize int) netConn.IMsgHandle + func NewService(config *Config) netConn.IService + func NewUdpConnection(server *UdpService, conn *net.UDPConn, connId uint64, remoteAddr net.Addr, ...) netConn.IConnection + func NewUdpService(config *Config) netConn.IService + type CallSendHandle struct + Buf []byte + CallFunc func(netConn.IConnection, bool, interface{}, error) + Param interface{} + type Config struct + AddrAry []string + BufferCount uint + BufferSize uint + Network string + SendDataCount int + TaskQueueSize int + WorkerSize int + type ConnManager struct + func (connMgr *ConnManager) Add(conn netConn.IConnection) + func (connMgr *ConnManager) ClearConn() + func (connMgr *ConnManager) Get(connID uint64) (netConn.IConnection, bool) + func (connMgr *ConnManager) Len() int + func (connMgr *ConnManager) Remove(conn netConn.IConnection) + type Connection struct + Conn net.Conn + ConnId uint64 + ExitBuffChan chan bool + HeartTime time.Time + MsgHandler netConn.IMsgHandle + PackCount int64 + Receiver []netConn.IReceiver + Server *Service + func (c *Connection) GetBytesCache() *bytes.Buffer + func (c *Connection) GetConnId() uint64 + func (c *Connection) GetNetConn() net.Conn + func (c *Connection) GetPackCount() int64 + func (c *Connection) GetProperty(key string) (interface{}, error) + func (c *Connection) GetReceiver() []netConn.IReceiver + func (c *Connection) GetRemoteAddr() net.Addr + func (c *Connection) OnCompleted(data []byte, offset int, count int) + func (c *Connection) OnReceiveCompleted(data []byte) + func (c *Connection) RemoveProperty(key string) + func (c *Connection) SendData(data []byte) error + func (c *Connection) SendDataCall(data []byte, param interface{}, ...) error + func (c *Connection) SetProperty(key string, value interface{}) + func (c *Connection) Start() + func (c *Connection) Stop() + type MsgHandle struct + ExitMsgChan []chan bool + TaskQueue []chan netConn.IRequest + func (mh *MsgHandle) DoMsgHandler(request netConn.IRequest) + func (mh *MsgHandle) SendMsgToTaskQueue(request netConn.IRequest) + func (mh *MsgHandle) StartOneWorker(workerID int, taskQueue chan netConn.IRequest) + func (mh *MsgHandle) StartWorkerPool() + func (mh *MsgHandle) StopWorkerPool() + type Request struct + Conn netConn.IConnection + Count int + Data []byte + func (r *Request) GetConnection() netConn.IConnection + func (r *Request) GetCount() int + func (r *Request) GetData() []byte + type Service struct + BufferPool *util.BufferPool + ConnId uint64 + ConnMgr netConn.IConnManager + CreateReceiver func(conn netConn.IConnection, data []byte) []netConn.IReceiver + ExitServiceChan chan bool + OnConnStart func(conn netConn.IConnection) + OnConnStop func(conn netConn.IConnection) + OnErrorHandle func(level string, msg string) + OnReceiveCompleted func(conn netConn.IConnection, data []byte) + func (s *Service) CallErrorhandle(level string, msg ...string) + func (s *Service) CallOnConnStart(conn netConn.IConnection) + func (s *Service) CallOnConnStop(conn netConn.IConnection) + func (s *Service) CallOnReceiveCompleted(conn netConn.IConnection, data []byte) + func (s *Service) GetConn(connId uint64) (netConn.IConnection, bool) + func (s *Service) GetConnId() uint64 + func (s *Service) GetConnMgr() netConn.IConnManager + func (s *Service) SetCreateReceiver(hookFunc func(netConn.IConnection, []byte) []netConn.IReceiver) + func (s *Service) SetErrorHandle(hookFunc func(level string, msg string)) + func (s *Service) SetOnConnStart(hookFunc func(netConn.IConnection)) + func (s *Service) SetOnConnStop(hookFunc func(netConn.IConnection)) + func (s *Service) SetOnReceiveCompleted(hookFunc func(netConn.IConnection, []byte)) + func (s *Service) Start() + func (s *Service) Stop() + type UdpConnection struct + Conn *net.UDPConn + ConnId uint64 + ExitBuffChan chan bool + HeartTime time.Time + MsgHandler netConn.IMsgHandle + PackCount int64 + RemoteAddr net.Addr + Server *UdpService + func (c *UdpConnection) GetBytesCache() *bytes.Buffer + func (c *UdpConnection) GetConnId() uint64 + func (c *UdpConnection) GetPackCount() int64 + func (c *UdpConnection) GetProperty(key string) (interface{}, error) + func (c *UdpConnection) GetRemoteAddr() net.Addr + func (c *UdpConnection) OnCompleted(data []byte, offset int, count int) + func (c *UdpConnection) OnReceiveCompleted(data []byte) + func (c *UdpConnection) RemoveProperty(key string) + func (c *UdpConnection) SendData(data []byte) error + func (c *UdpConnection) SendDataCall(data []byte, param interface{}, ...) error + func (c *UdpConnection) SetProperty(key string, value interface{}) + func (c *UdpConnection) Start() + func (c *UdpConnection) Stop() + type UdpService struct + BufferPool *util.BufferPool + ConnId uint64 + ConnMgr netConn.IConnManager + ConnectionsMap map[string]uint64 + CreateReceiver func(conn netConn.IConnection, data []byte) []netConn.IReceiver + ExitServiceChan chan bool + OnConnStart func(conn netConn.IConnection) + OnConnStop func(conn netConn.IConnection) + OnErrorHandle func(level string, msg string) + OnReceiveCompleted func(conn netConn.IConnection, data []byte) + func (s *UdpService) CallErrorhandle(level string, msgs ...string) + func (s *UdpService) CallOnConnStart(conn netConn.IConnection) + func (s *UdpService) CallOnConnStop(conn netConn.IConnection) + func (s *UdpService) CallOnReceiveCompleted(conn netConn.IConnection, data []byte) + func (s *UdpService) GetConn(connId uint64) (netConn.IConnection, bool) + func (s *UdpService) GetConnId() uint64 + func (s *UdpService) GetConnMgr() netConn.IConnManager + func (s *UdpService) SetCreateReceiver(hookFunc func(netConn.IConnection, []byte) []netConn.IReceiver) + func (s *UdpService) SetErrorHandle(hookFunc func(level string, msg string)) + func (s *UdpService) SetOnConnStart(hookFunc func(netConn.IConnection)) + func (s *UdpService) SetOnConnStop(hookFunc func(netConn.IConnection)) + func (s *UdpService) SetOnReceiveCompleted(hookFunc func(netConn.IConnection, []byte)) + func (s *UdpService) Start() + func (s *UdpService) Stop()