Documentation ¶
Index ¶
- func NewServer(conf *zconfig.ZConfig) ziface.IServer
- type ConnManager
- type Connection
- func (c *Connection) GetConnID() uint64
- func (c *Connection) GetProperty(key string) (any, bool)
- func (c *Connection) GetTCPConnection() *net.TCPConn
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) RemoveProperty(key string)
- func (c *Connection) SendMsg(id uint32, data []byte) error
- func (c *Connection) SetProperty(key string, value any)
- func (c *Connection) Start(ctx context.Context)
- func (c *Connection) Stop()
- type DataPack
- type Message
- type MsgHandle
- type Request
- type Server
- func (s *Server) AddRouter(msgID uint32, handle ziface.HandleFunc)
- func (s *Server) CallOnConnStart(conn ziface.IConnection)
- func (s *Server) CallOnConnStop(conn ziface.IConnection)
- func (s *Server) Config() *zconfig.ZConfig
- func (s *Server) GetConnMgr() ziface.IConnManager
- func (s *Server) NotifyClose(c ziface.IConnection)
- func (s *Server) Serve()
- func (s *Server) SetOnConnStart(f func(conn ziface.IConnection))
- func (s *Server) SetOnConnStop(f func(conn ziface.IConnection))
- func (s *Server) Start()
- func (s *Server) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
func NewConnManager ¶
func NewConnManager() *ConnManager
func (*ConnManager) Add ¶
func (cm *ConnManager) Add(conn ziface.IConnection)
func (*ConnManager) ClearConn ¶
func (cm *ConnManager) ClearConn()
func (*ConnManager) Get ¶
func (cm *ConnManager) Get(connID uint64) (ziface.IConnection, error)
func (*ConnManager) Len ¶
func (cm *ConnManager) Len() int
func (*ConnManager) Remove ¶
func (cm *ConnManager) Remove(conn ziface.IConnection)
type Connection ¶
type Connection struct { TCPServer ziface.IServer Conn *net.TCPConn ConnID uint64 MsgHandler ziface.IMsgHandle ExitBuffChan chan struct{} // contains filtered or unexported fields }
func NewConnection ¶
func NewConnection(server ziface.IServer, conn *net.TCPConn, connID uint64, mh ziface.IMsgHandle) *Connection
func (*Connection) GetConnID ¶
func (c *Connection) GetConnID() uint64
func (*Connection) GetProperty ¶
func (c *Connection) GetProperty(key string) (any, bool)
func (*Connection) GetTCPConnection ¶
func (c *Connection) GetTCPConnection() *net.TCPConn
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
func (*Connection) RemoveProperty ¶
func (c *Connection) RemoveProperty(key string)
func (*Connection) SetProperty ¶
func (c *Connection) SetProperty(key string, value any)
func (*Connection) Start ¶
func (c *Connection) Start(ctx context.Context)
func (*Connection) Stop ¶
func (c *Connection) Stop()
type DataPack ¶
type DataPack struct {
// contains filtered or unexported fields
}
func NewDataPack ¶
func (*DataPack) GetHeadLen ¶
type MsgHandle ¶
type MsgHandle struct { Apis map[uint32]ziface.HandleFunc TaskQueue []chan ziface.IRequest // contains filtered or unexported fields }
func NewMsgHandle ¶
func (*MsgHandle) AddRouter ¶
func (mh *MsgHandle) AddRouter(msgID uint32, handle ziface.HandleFunc)
func (*MsgHandle) DoMsgHandle ¶
func (*MsgHandle) SendMsgToTaskQueue ¶
func (*MsgHandle) StarWorkerPool ¶
func (mh *MsgHandle) StarWorkerPool()
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) GetConnection ¶
func (r *Request) GetConnection() ziface.IConnection
type Server ¶
type Server struct { ConnIDGen atomic.Uint64 // TODO: use distributed unique id to support multiple servers ConnMgr ziface.IConnManager // contains filtered or unexported fields }
func (*Server) CallOnConnStart ¶
func (s *Server) CallOnConnStart(conn ziface.IConnection)
func (*Server) CallOnConnStop ¶
func (s *Server) CallOnConnStop(conn ziface.IConnection)
func (*Server) GetConnMgr ¶
func (s *Server) GetConnMgr() ziface.IConnManager
func (*Server) NotifyClose ¶
func (s *Server) NotifyClose(c ziface.IConnection)
func (*Server) SetOnConnStart ¶
func (s *Server) SetOnConnStart(f func(conn ziface.IConnection))
func (*Server) SetOnConnStop ¶
func (s *Server) SetOnConnStop(f func(conn ziface.IConnection))
Click to show internal directories.
Click to hide internal directories.