Documentation ¶
Index ¶
- func EqualNID(nid1 context.NodeID, nid2 context.NodeID) bool
- func EqualSID(sid1 *protocol.SERVER_ID, sid2 *protocol.SERVER_ID) bool
- func NewNID(ctx *common.Context, t config.NodeType) context.NodeID
- func NodeID2ServerID(nid context.NodeID) *protocol.SERVER_ID
- func ServerID2NodeID(sid *protocol.SERVER_ID) context.NodeID
- type DefaultNodeInterfaceImpl
- func (impl *DefaultNodeInterfaceImpl) EnableMessageRelay(v bool)
- func (impl *DefaultNodeInterfaceImpl) FuncOnLoseAccount() context.FuncTypeOnLoseAccount
- func (impl *DefaultNodeInterfaceImpl) FuncOnRelayMsg() context.FuncTypeOnRelayMsg
- func (impl *DefaultNodeInterfaceImpl) GetID() context.NodeID
- func (impl *DefaultNodeInterfaceImpl) GetIP(i utils.IPType) string
- func (impl *DefaultNodeInterfaceImpl) GetNode(nodeID context.NodeID) *SessionBase
- func (impl *DefaultNodeInterfaceImpl) GetNodeAll() []*SessionBase
- func (impl *DefaultNodeInterfaceImpl) GetNodeList(nodeType config.NodeType) []*SessionBase
- func (impl *DefaultNodeInterfaceImpl) GetNodeOne(nodeType config.NodeType) *SessionBase
- func (impl *DefaultNodeInterfaceImpl) GetOverload(i int) uint32
- func (impl *DefaultNodeInterfaceImpl) GetPort(i int) int32
- func (impl *DefaultNodeInterfaceImpl) GetSID() *protocol.SERVER_ID
- func (impl *DefaultNodeInterfaceImpl) GetType() config.NodeType
- func (impl *DefaultNodeInterfaceImpl) GetVersion() string
- func (impl *DefaultNodeInterfaceImpl) HaveNode(nodeID context.NodeID) bool
- func (impl *DefaultNodeInterfaceImpl) IsEnableMessageRelay() bool
- func (impl *DefaultNodeInterfaceImpl) PrintAllNodeInfo(log context.ILogger)
- func (impl *DefaultNodeInterfaceImpl) PrintNodeInfo(log context.ILogger, nodeType config.NodeType)
- func (impl *DefaultNodeInterfaceImpl) RegisterFuncOnLoseAccount(f context.FuncTypeOnLoseAccount)
- func (impl *DefaultNodeInterfaceImpl) RegisterFuncOnRelayMsg(f context.FuncTypeOnRelayMsg)
- func (impl *DefaultNodeInterfaceImpl) SendAll(cmd uint64, msg proto.Message, excludeSelf bool)
- func (impl *DefaultNodeInterfaceImpl) SendByID(nodeID context.NodeID, cmd uint64, msg proto.Message) bool
- func (impl *DefaultNodeInterfaceImpl) SendByType(nodeType config.NodeType, cmd uint64, msg proto.Message, excludeSelf bool)
- func (impl *DefaultNodeInterfaceImpl) SendOne(nodeType config.NodeType, cmd uint64, msg proto.Message) bool
- type ISessionDerived
- type Node
- func (node *Node) BroadcastMsgToClient(cmd uint64, data []byte, flag uint8) bool
- func (node *Node) BroadcastMsgToServer(t config.NodeType, cmd uint64, data []byte, flag uint8) bool
- func (node *Node) Close()
- func (node *Node) Init(sessType interface{}, components []utils.IComponent) bool
- func (node *Node) ReplyMsgToServer(targetID context.NodeID, cmd uint64, data []byte, flag uint8) bool
- func (node *Node) SendMsgToClient(account string, cmd uint64, data []byte, flag uint8) bool
- func (node *Node) SendMsgToServer(t config.NodeType, cmd uint64, data []byte, flag uint8) bool
- func (node *Node) Start() bool
- type SessionBase
- type SessionMgr
- func (sessmgr *SessionMgr) ForAll(f func(*SessionBase))
- func (sessmgr *SessionMgr) ForByType(t config.NodeType, f func(*SessionBase))
- func (sessmgr *SessionMgr) GetAll() []*SessionBase
- func (sessmgr *SessionMgr) GetByID(nid context.NodeID) *SessionBase
- func (sessmgr *SessionMgr) GetByType(t config.NodeType) []*SessionBase
- func (sessmgr *SessionMgr) Lose1(sess *SessionBase)
- func (sessmgr *SessionMgr) Lose2(sid *protocol.SERVER_ID, t config.NodeType)
- func (sessmgr *SessionMgr) Register(sess *SessionBase)
- func (sessmgr *SessionMgr) SelectOne(t config.NodeType) *SessionBase
- type UserData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodeID2ServerID ¶
NodeID2ServerID : context.NodeID 转化为 protocol.SERVER_ID
Types ¶
type DefaultNodeInterfaceImpl ¶
type DefaultNodeInterfaceImpl struct { Info *protocol.SERVER_INFO SessMgr *SessionMgr // contains filtered or unexported fields }
DefaultNodeInterfaceImpl : 缺省的节点接口实现
func (*DefaultNodeInterfaceImpl) EnableMessageRelay ¶
func (impl *DefaultNodeInterfaceImpl) EnableMessageRelay(v bool)
EnableMessageRelay : 开启消息中继功能。开启该功能的节点,会连接 Gateway 。 C -> Gateway -> Node ; Node1 -> Gateway -> Node2(s)
func (*DefaultNodeInterfaceImpl) FuncOnLoseAccount ¶
func (impl *DefaultNodeInterfaceImpl) FuncOnLoseAccount() context.FuncTypeOnLoseAccount
FuncOnLoseAccount : 获取`自定义处理丢失账号`的函数句柄
func (*DefaultNodeInterfaceImpl) FuncOnRelayMsg ¶
func (impl *DefaultNodeInterfaceImpl) FuncOnRelayMsg() context.FuncTypeOnRelayMsg
FuncOnRelayMsg : 获取`自定义处理Gateway中继过来的消息`的函数句柄
func (*DefaultNodeInterfaceImpl) GetID ¶
func (impl *DefaultNodeInterfaceImpl) GetID() context.NodeID
GetID : 获取本节点信息,节点ID
func (*DefaultNodeInterfaceImpl) GetIP ¶
func (impl *DefaultNodeInterfaceImpl) GetIP(i utils.IPType) string
GetIP : 获取本节点信息,IP
func (*DefaultNodeInterfaceImpl) GetNode ¶
func (impl *DefaultNodeInterfaceImpl) GetNode(nodeID context.NodeID) *SessionBase
GetNode : 获取节点
func (*DefaultNodeInterfaceImpl) GetNodeAll ¶
func (impl *DefaultNodeInterfaceImpl) GetNodeAll() []*SessionBase
GetNodeAll : 获取所有节点
func (*DefaultNodeInterfaceImpl) GetNodeList ¶
func (impl *DefaultNodeInterfaceImpl) GetNodeList(nodeType config.NodeType) []*SessionBase
GetNodeList : 获取某类型节点列表
func (*DefaultNodeInterfaceImpl) GetNodeOne ¶
func (impl *DefaultNodeInterfaceImpl) GetNodeOne(nodeType config.NodeType) *SessionBase
GetNodeOne : 根据节点类型,随机选择 1 节点
func (*DefaultNodeInterfaceImpl) GetOverload ¶
func (impl *DefaultNodeInterfaceImpl) GetOverload(i int) uint32
GetOverload : 获取本节点信息,负载
func (*DefaultNodeInterfaceImpl) GetPort ¶
func (impl *DefaultNodeInterfaceImpl) GetPort(i int) int32
GetPort : 获取本节点信息,端口
func (*DefaultNodeInterfaceImpl) GetSID ¶
func (impl *DefaultNodeInterfaceImpl) GetSID() *protocol.SERVER_ID
GetSID : 获取 SID
func (*DefaultNodeInterfaceImpl) GetType ¶
func (impl *DefaultNodeInterfaceImpl) GetType() config.NodeType
GetType : 获取节点类型
func (*DefaultNodeInterfaceImpl) GetVersion ¶
func (impl *DefaultNodeInterfaceImpl) GetVersion() string
GetVersion : 获取本节点信息,版本号
func (*DefaultNodeInterfaceImpl) HaveNode ¶
func (impl *DefaultNodeInterfaceImpl) HaveNode(nodeID context.NodeID) bool
HaveNode : 是否有节点
func (*DefaultNodeInterfaceImpl) IsEnableMessageRelay ¶
func (impl *DefaultNodeInterfaceImpl) IsEnableMessageRelay() bool
IsEnableMessageRelay : 是否开启了消息中继功能
func (*DefaultNodeInterfaceImpl) PrintAllNodeInfo ¶
func (impl *DefaultNodeInterfaceImpl) PrintAllNodeInfo(log context.ILogger)
PrintAllNodeInfo : 打印节点信息
func (*DefaultNodeInterfaceImpl) PrintNodeInfo ¶
func (impl *DefaultNodeInterfaceImpl) PrintNodeInfo(log context.ILogger, nodeType config.NodeType)
PrintNodeInfo : 打印节点信息
func (*DefaultNodeInterfaceImpl) RegisterFuncOnLoseAccount ¶
func (impl *DefaultNodeInterfaceImpl) RegisterFuncOnLoseAccount(f context.FuncTypeOnLoseAccount)
RegisterFuncOnLoseAccount : 注册自定义处理`丢失账号`
func (*DefaultNodeInterfaceImpl) RegisterFuncOnRelayMsg ¶
func (impl *DefaultNodeInterfaceImpl) RegisterFuncOnRelayMsg(f context.FuncTypeOnRelayMsg)
RegisterFuncOnRelayMsg : 注册自定义处理Gateway中继过来的消息
func (*DefaultNodeInterfaceImpl) SendAll ¶
func (impl *DefaultNodeInterfaceImpl) SendAll(cmd uint64, msg proto.Message, excludeSelf bool)
SendAll : 对服务器组,广播数据
func (*DefaultNodeInterfaceImpl) SendByID ¶
func (impl *DefaultNodeInterfaceImpl) SendByID(nodeID context.NodeID, cmd uint64, msg proto.Message) bool
SendByID : 往指定节点,发送数据
func (*DefaultNodeInterfaceImpl) SendByType ¶
func (impl *DefaultNodeInterfaceImpl) SendByType(nodeType config.NodeType, cmd uint64, msg proto.Message, excludeSelf bool)
SendByType : 对某类型节点,广播数据
type ISessionDerived ¶
type ISessionDerived interface { DoVerify(msg *protocol.MSG_MGR_REGISTER_SERVER) DoRegister(msg *protocol.MSG_MGR_REGISTER_SERVER) DoLose(msg *protocol.MSG_MGR_LOSE_SERVER) DoClose(sessbase *SessionBase) DoRecv(cmd uint64, data []byte, flag byte) (done bool) }
ISessionDerived : SessionBase 派生类接口定义
type Node ¶
type Node struct { Ctx *common.Context DefaultNodeInterfaceImpl // contains filtered or unexported fields }
Node : 管理节点基类
func (*Node) BroadcastMsgToClient ¶
BroadcastMsgToClient : 广播消息给客户端,通过 Gateway 中继
func (*Node) BroadcastMsgToServer ¶
BroadcastMsgToServer : 广播消息给某类型服务
func (*Node) Init ¶
func (node *Node) Init(sessType interface{}, components []utils.IComponent) bool
Init : 初始化节点
func (*Node) ReplyMsgToServer ¶
func (node *Node) ReplyMsgToServer(targetID context.NodeID, cmd uint64, data []byte, flag uint8) bool
ReplyMsgToServer : 回发消息给请求服务器
func (*Node) SendMsgToClient ¶
SendMsgToClient : 发送消息给客户端,通过 Gateway 中继
func (*Node) SendMsgToServer ¶
SendMsgToServer : 发送消息给某类型服务(随机一个)
type SessionBase ¶
type SessionBase struct { DefaultNodeInterfaceImpl *gotcp.Session Ctx *common.Context CacheRegisterMsg *protocol.MSG_MGR_REGISTER_SERVER // contains filtered or unexported fields }
SessionBase : 网络会话类
func NewSessionBase ¶
func NewSessionBase(ctx *common.Context, derived ISessionDerived) *SessionBase
NewSessionBase : 网络会话类的构造函数
func (*SessionBase) OnRecv ¶
func (sessbase *SessionBase) OnRecv(data []byte, flag byte)
OnRecv : 接收到网络数据包,被触发
type SessionMgr ¶
type SessionMgr struct {
// contains filtered or unexported fields
}
SessionMgr : 网络会话对象管理类
func NewSessionMgr ¶
func NewSessionMgr(ctx *common.Context) *SessionMgr
NewSessionMgr : 实例化网络会话对象管理类
func (*SessionMgr) ForAll ¶
func (sessmgr *SessionMgr) ForAll(f func(*SessionBase))
ForAll : 遍历所有网络会话节点
func (*SessionMgr) ForByType ¶
func (sessmgr *SessionMgr) ForByType(t config.NodeType, f func(*SessionBase))
ForByType : 根据类型遍历网络会话节点
func (*SessionMgr) GetAll ¶
func (sessmgr *SessionMgr) GetAll() []*SessionBase
GetAll : 获取所有网络会话节点列表
func (*SessionMgr) GetByID ¶
func (sessmgr *SessionMgr) GetByID(nid context.NodeID) *SessionBase
GetByID : 根据 NID 获取网络会话节点
func (*SessionMgr) GetByType ¶
func (sessmgr *SessionMgr) GetByType(t config.NodeType) []*SessionBase
GetByType : 根据节点类型,获取某类网络会话节点列表
func (*SessionMgr) Lose2 ¶
func (sessmgr *SessionMgr) Lose2(sid *protocol.SERVER_ID, t config.NodeType)
Lose2 : 丢失网络会话节点
func (*SessionMgr) Register ¶
func (sessmgr *SessionMgr) Register(sess *SessionBase)
Register : 有网络会话节点加入
func (*SessionMgr) SelectOne ¶
func (sessmgr *SessionMgr) SelectOne(t config.NodeType) *SessionBase
SelectOne : 选择 1 个某类型的网络会话节点
type UserData ¶
type UserData struct { Ctx *common.Context SessMgr *SessionMgr }
UserData : 传递给 Session 的数据