Documentation
¶
Index ¶
- func NewServer() ziface.IServer
- type BaseRouter
- type Connection
- func (c *Connection) GetConnID() uint32
- func (c *Connection) GetRemoteAddr() net.Addr
- func (c *Connection) GetTCPConnection() *net.TCPConn
- func (c *Connection) SendMsg(msgId uint32, data []byte) error
- func (c *Connection) Start()
- func (c *Connection) StartReader()
- func (c *Connection) StartWriter()
- func (c *Connection) Stop()
- type DataPack
- type Message
- type MsgHandle
- type Request
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseRouter ¶
type BaseRouter struct {
}
实现router时,先嵌入这个BaseRouter基类,然后根据需要对这个基类的方法重写
func (*BaseRouter) PostHandle ¶
func (br *BaseRouter) PostHandle(request ziface.IRequest)
在处理conn业务之后的钩子方法Hook
func (*BaseRouter) PreHandle ¶
func (br *BaseRouter) PreHandle(request ziface.IRequest)
这里之所以BaseRouter的方法都为空,是有的Router不希望有PreHandle/PostHandle 在处理conn业务之前的钩子方法Hook
type Connection ¶
type Connection struct {
// 当前连接的socket TCP套接字
Conn *net.TCPConn
// 连接的ID
ConnID uint32
// 当前的连接状态
IsClosed bool
// 告知当前连接已经退出 channel
ExitBuffChan chan bool
// 消息管理MsgId和对应处理方法的消息管理模块
MsgHandler ziface.IMsgHandle
// contains filtered or unexported fields
}
连接模块
func NewConnection ¶
func NewConnection(conn *net.TCPConn, connID uint32, msgHandler ziface.IMsgHandle) *Connection
初始化连接模块的方法
func (*Connection) GetRemoteAddr ¶
func (c *Connection) GetRemoteAddr() net.Addr
获取远程客户端的TCP状态的IP port
func (*Connection) GetTCPConnection ¶
func (c *Connection) GetTCPConnection() *net.TCPConn
获取当前连接的绑定socket conn
type MsgHandle ¶
func NewMsgHandle ¶
func NewMsgHandle() *MsgHandle
func (*MsgHandle) DoMsgHandler ¶
马上以非阻塞方式处理消息
Click to show internal directories.
Click to hide internal directories.