Documentation ¶
Index ¶
- Constants
- type BaseRouter
- type ConnManager
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) Closed() bool
- func (c *Connection) GetConnID() uint32
- func (c *Connection) GetConnection() net.Conn
- func (c *Connection) GetMsgBuffChan() <-chan *Message
- func (c *Connection) GetMsgChan() <-chan *Message
- func (c *Connection) GetProperty(key string) (interface{}, error)
- func (c *Connection) GetTcpConnection() *net.TCPConn
- func (c *Connection) GetUpdateTime() int64
- func (c *Connection) GetWebsocketConnection() *websocket.Conn
- func (c *Connection) OnlineDuration() int64
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) RemoveProperty(key string)
- func (c *Connection) SendBuffMsg(msgId byte, data []byte) error
- func (c *Connection) SendMsg(msgId byte, data []byte) error
- func (c *Connection) SetOnClose(hookFunc func(*Connection))
- func (c *Connection) SetProperty(key string, value interface{})
- func (c *Connection) SetTcpConn(tcpConn *net.TCPConn)
- func (c *Connection) SetWebsocketConn(websocketConn *websocket.Conn)
- func (c *Connection) UpdateTime()
- type IRouter
- type Message
- type MsgHandle
- func (mh *MsgHandle) AddRouter(msgId byte, router IRouter)
- func (mh *MsgHandle) DoMsgHandler(request *Request)
- func (mh *MsgHandle) DoReceive(request *Request)
- func (mh *MsgHandle) SendMsgToTaskQueue(request *Request)
- func (mh *MsgHandle) StartOneWorker(workerID int, taskQueue chan *Request)
- func (mh *MsgHandle) StartWorkerPool()
- type Request
Constants ¶
View Source
const ( Tcp = iota Websocket )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRouter ¶
type BaseRouter struct{}
func (*BaseRouter) Handle ¶
func (br *BaseRouter) Handle(req *Request)
func (*BaseRouter) PostHandle ¶
func (br *BaseRouter) PostHandle(req *Request)
func (*BaseRouter) PreHandle ¶
func (br *BaseRouter) PreHandle(req *Request)
type ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
func NewConnManager ¶
func NewConnManager() *ConnManager
func (*ConnManager) Add ¶
func (connMgr *ConnManager) Add(conn *Connection)
func (*ConnManager) ClearConn ¶
func (connMgr *ConnManager) ClearConn()
func (*ConnManager) Get ¶
func (connMgr *ConnManager) Get(connID uint32) (*Connection, error)
func (*ConnManager) Len ¶
func (connMgr *ConnManager) Len() int
func (*ConnManager) Remove ¶
func (connMgr *ConnManager) Remove(conn *Connection)
func (*ConnManager) ShowConn ¶
func (connMgr *ConnManager) ShowConn()
type Connection ¶
type Connection struct { Conn net.Conn TcpConn *net.TCPConn WebsocketConn *websocket.Conn ConnID uint32 ExitBuffChan chan bool OnClose func(conn *Connection) // contains filtered or unexported fields }
func NewConnection ¶
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) Closed ¶
func (c *Connection) Closed() bool
func (*Connection) GetConnID ¶
func (c *Connection) GetConnID() uint32
func (*Connection) GetConnection ¶
func (c *Connection) GetConnection() net.Conn
func (*Connection) GetMsgBuffChan ¶
func (c *Connection) GetMsgBuffChan() <-chan *Message
func (*Connection) GetMsgChan ¶
func (c *Connection) GetMsgChan() <-chan *Message
func (*Connection) GetProperty ¶
func (c *Connection) GetProperty(key string) (interface{}, error)
func (*Connection) GetTcpConnection ¶
func (c *Connection) GetTcpConnection() *net.TCPConn
func (*Connection) GetUpdateTime ¶
func (c *Connection) GetUpdateTime() int64
func (*Connection) GetWebsocketConnection ¶
func (c *Connection) GetWebsocketConnection() *websocket.Conn
func (*Connection) OnlineDuration ¶
func (c *Connection) OnlineDuration() int64
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
func (*Connection) RemoveProperty ¶
func (c *Connection) RemoveProperty(key string)
func (*Connection) SendBuffMsg ¶
func (c *Connection) SendBuffMsg(msgId byte, data []byte) error
func (*Connection) SetOnClose ¶
func (c *Connection) SetOnClose(hookFunc func(*Connection))
func (*Connection) SetProperty ¶
func (c *Connection) SetProperty(key string, value interface{})
func (*Connection) SetTcpConn ¶
func (c *Connection) SetTcpConn(tcpConn *net.TCPConn)
func (*Connection) SetWebsocketConn ¶
func (c *Connection) SetWebsocketConn(websocketConn *websocket.Conn)
func (*Connection) UpdateTime ¶
func (c *Connection) UpdateTime()
type MsgHandle ¶
type MsgHandle struct { Apis map[byte]IRouter WorkerPoolSize uint32 TaskQueue []chan *Request MaxWorkerTaskLen uint32 }
func NewMsgHandle ¶
func (*MsgHandle) DoMsgHandler ¶
func (*MsgHandle) SendMsgToTaskQueue ¶
func (*MsgHandle) StartOneWorker ¶
func (*MsgHandle) StartWorkerPool ¶
func (mh *MsgHandle) StartWorkerPool()
Click to show internal directories.
Click to hide internal directories.