Documentation ¶
Index ¶
- func NewServer() aiface.IServer
- type BaseRouter
- type ConnManager
- type Connection
- func (c *Connection) GetConnID() uint32
- func (c *Connection) GetProperty(key string) (interface{}, error)
- func (c *Connection) GetRemoteAddr() net.Addr
- func (c *Connection) GetTCPConnection() *net.TCPConn
- func (c *Connection) RemoveProperty(key string)
- func (c *Connection) SendBuffMsg(msgId uint32, data []byte) error
- func (c *Connection) SendMsg(msgId uint32, 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
- type Message
- type MsgHandle
- func (mh *MsgHandle) AddRouter(msgId uint32, router aiface.IRouter)
- func (mh *MsgHandle) DoMsgHandler(request aiface.IRequest)
- func (mh *MsgHandle) SendMsgToTaskQueue(request aiface.IRequest)
- func (mh *MsgHandle) StartOneWorker(workerID int, taskQueue chan aiface.IRequest)
- func (mh *MsgHandle) StartWorkerPool()
- type Requst
- type Server
- func (s *Server) AddRouter(msgId uint32, router aiface.IRouter)
- func (s *Server) CallOnConnStart(conn aiface.IConnection)
- func (s *Server) CallOnConnStop(conn aiface.IConnection)
- func (s *Server) GetConnMgr() aiface.IConnManager
- func (s *Server) Serve()
- func (s *Server) SetOnConnStart(hookFunc func(aiface.IConnection))
- func (s *Server) SetOnConnStop(hookFunc func(aiface.IConnection))
- func (s *Server) Start()
- func (s *Server) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseRouter ¶
type BaseRouter struct { }
func (*BaseRouter) Handle ¶
func (br *BaseRouter) Handle(requst aiface.IRequest)
func (*BaseRouter) PostHandle ¶
func (br *BaseRouter) PostHandle(requst aiface.IRequest)
func (*BaseRouter) PreHandle ¶
func (br *BaseRouter) PreHandle(requst aiface.IRequest)
type ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
Connection management module
func NewConnManager ¶
func NewConnManager() *ConnManager
func (*ConnManager) Add ¶
func (connMgr *ConnManager) Add(conn aiface.IConnection)
func (*ConnManager) ClearConn ¶
func (connMgr *ConnManager) ClearConn()
func (*ConnManager) Get ¶
func (connMgr *ConnManager) Get(connID uint32) (aiface.IConnection, error)
get connection by connID
func (*ConnManager) Len ¶
func (connMgr *ConnManager) Len() int
func (*ConnManager) Remove ¶
func (connMgr *ConnManager) Remove(conn aiface.IConnection)
type Connection ¶
type Connection struct { TcpServer aiface.IServer // Currently connected socket Conn *net.TCPConn ConnID uint32 //inform the channel that the current connection has exited and stopped ExitChan chan bool MsgHandler aiface.IMsgHandle // contains filtered or unexported fields }
func NewConnection ¶
func NewConnection(server aiface.IServer, conn *net.TCPConn, connID uint32, msgHandler aiface.IMsgHandle) *Connection
initialize the connection module
func (*Connection) GetConnID ¶
func (c *Connection) GetConnID() uint32
func (*Connection) GetProperty ¶
func (c *Connection) GetProperty(key string) (interface{}, error)
Get connection properties
func (*Connection) GetRemoteAddr ¶
func (c *Connection) GetRemoteAddr() net.Addr
func (*Connection) GetTCPConnection ¶
func (c *Connection) GetTCPConnection() *net.TCPConn
func (*Connection) RemoveProperty ¶
func (c *Connection) RemoveProperty(key string)
remove connection properties
func (*Connection) SendBuffMsg ¶
func (c *Connection) SendBuffMsg(msgId uint32, data []byte) error
func (*Connection) SetProperty ¶
func (c *Connection) SetProperty(key string, value interface{})
func (*Connection) Start ¶
func (c *Connection) Start()
func (*Connection) StartReader ¶
func (c *Connection) StartReader()
func (*Connection) Stop ¶
func (c *Connection) Stop()
type DataPack ¶
type DataPack struct { }
func NewDataPack ¶
func NewDataPack() *DataPack
func (*DataPack) GetHeadLen ¶
type MsgHandle ¶
type MsgHandle struct { // 存放每个MsgId所对应的处理方法 Apis map[uint32]aiface.IRouter //存放每个MsgId 所对应的处理方法的map属性 // worker池数量 WorkerPoolSize uint32 //Worker负责取任务的消息队列 TaskQueue []chan aiface.IRequest }
func (*MsgHandle) DoMsgHandler ¶
马上以非阻塞方式处理消息
func (*MsgHandle) SendMsgToTaskQueue ¶
将消息交给TaskQueue,由worker进行处理
func (*MsgHandle) StartOneWorker ¶
type Requst ¶
type Requst struct {
// contains filtered or unexported fields
}
func (*Requst) GetConnection ¶
func (r *Requst) GetConnection() aiface.IConnection
type Server ¶
type Server struct { Name string //IP version bound to the server IPVersion string IP string //The port the server is listening on Port int //connection manager of the current server ConnMgr aiface.IConnManager OnConnStart func(conn aiface.IConnection) OnConnStop func(conn aiface.IConnection) // contains filtered or unexported fields }
func (*Server) CallOnConnStart ¶
func (s *Server) CallOnConnStart(conn aiface.IConnection)
Call the connection OnConnStart Hook function
func (*Server) CallOnConnStop ¶
func (s *Server) CallOnConnStop(conn aiface.IConnection)
func (*Server) GetConnMgr ¶
func (s *Server) GetConnMgr() aiface.IConnManager
func (*Server) SetOnConnStart ¶
func (s *Server) SetOnConnStart(hookFunc func(aiface.IConnection))
func (*Server) SetOnConnStop ¶
func (s *Server) SetOnConnStop(hookFunc func(aiface.IConnection))
Source Files ¶
Click to show internal directories.
Click to hide internal directories.