Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IConnManager ¶
type IConnManager interface {
// AddConn 添加连接
AddConn(conn IConnection)
// RemoveConn 删除连接
RemoveConn(conn IConnection)
// GetConn 根据connID获取连接
GetConn(connID uint32) (IConnection, error)
// GetConnCount 得到当前连接总数
GetConnCount() int
// ClearConn 清理并终止所有的连接
ClearConn()
}
type IConnection ¶
type IConnection interface {
// Start 启动连接 让当前的连接准备开始工作
Start()
// Stop 停止连接 结束当前连接的工作
Stop()
// GetTcpConnection 获取当前连接的绑定的socket conn
GetTcpConnection() *net.TCPConn
// GetConnID 获取当前连接模块的连接ID
GetConnID() uint32
// RemoteAddr 获取远程客户端的 TCP状态 IP port
RemoteAddr() net.Addr
// SendMsg 发送消息, 将数据发送给远程的客户端
SendMsg(msgId uint32, data []byte) error
// SetProperty 设置连接属性
SetProperty(key string, value interface{})
// GetProperty 获取连接属性
GetProperty(key string) (interface{}, error)
// RemoveProperty 删除连接属性
RemoveProperty(key string)
}
IConnection 定义连接模块的抽象层
type IDataPacket ¶
type IMsgHandler ¶
type IMsgHandler interface {
// DoMsgHandler 调度/执行对应的Router消息处理方法
DoMsgHandler(request IRequest)
// AddRouter 为消息添加具体的处理逻辑
AddRouter(msgId uint32, router IRouter)
// StartWorkerPool 启动Worker工作池
StartWorkerPool()
// SendMsgToTaskQueue 将消息交给TaskQueue, 由Worker进行管理
SendMsgToTaskQueue(request IRequest)
}
type IRequest ¶
type IRequest interface {
// GetConnection 得到当前连接
GetConnection() IConnection
// GetMessageBody 获取消息数据
GetMessageBody() []byte
// GetMessageID 获取消息的ID
GetMessageID() uint32
// GetMessageLen 获得消息的长度
GetMessageLen() uint32
}
type IServer ¶
type IServer interface {
// Start 启动服务器
Start()
// Stop 停止服务器
Stop()
// Run 运行服务器
Run()
// AddRouter 路由功能:给当前的服务注册一个路由方法;供客户端的连接处理使用
AddRouter(msgID uint32, router IRouter)
// GetConnMgr 获取当前Server的ConnMgr
GetConnMgr() IConnManager
// GetMsgHandler 获取当前Server的ConnMgr
GetMsgHandler() IMsgHandler
// SetOnConnStart 注册OnConnStar 钩子函数的方法
SetOnConnStart(f func(connection IConnection))
// CallOnConnStart 调用OnConnStart 钩子函数的方法
CallOnConnStart(connection IConnection)
// SetOnConnClose 注册OnConnClose 钩子函数的方法
SetOnConnClose(f func(connection IConnection))
// CallOnConnClose 调用OnConnClose 钩子函数的方法
CallOnConnClose(connection IConnection)
}
Click to show internal directories.
Click to hide internal directories.