Documentation ¶
Index ¶
- Constants
- func NewLocalSession(module IGateModule, data map[string]interface{}) (s core.IUserSession, err error)
- func NewRemoteSession(service base.IClusterService, data map[string]interface{}) (s core.IUserSession, err error)
- type AgentBase
- func (this *AgentBase) Destory()
- func (this *AgentBase) IP() string
- func (this *AgentBase) Id() string
- func (this *AgentBase) IsClosed() bool
- func (this *AgentBase) OnClose()
- func (this *AgentBase) OnInit(module IGateModule, coon IConn, agent IAgent) (err error)
- func (this *AgentBase) OnRecover(msg proto.IMessage)
- func (this *AgentBase) OnRun()
- func (this *AgentBase) RevNum() int64
- func (this *AgentBase) SendNum() int64
- func (this *AgentBase) WriteMsg(msg proto.IMessage) error
- type AgentMgrComp
- func (this *AgentMgrComp) Close(aId string) (result string, err string)
- func (this *AgentMgrComp) Connect(a IAgent)
- func (this *AgentMgrComp) Destroy() (err error)
- func (this *AgentMgrComp) DisConnect(a IAgent)
- func (this *AgentMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, ...) (err error)
- func (this *AgentMgrComp) SendMsg(aId string, msg proto.IMessage) (result int, err string)
- func (this *AgentMgrComp) SendMsgByBroadcast(msg proto.IMessage) (result int, err string)
- func (this *AgentMgrComp) SendMsgByGroup(aIds []string, msg proto.IMessage) (result []string, err string)
- type CustomRouteComp
- func (this *CustomRouteComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, ...) (err error)
- func (this *CustomRouteComp) OnRoute(agent IAgent, msg proto.IMessage) (code core.ErrorCode, err error)
- func (this *CustomRouteComp) RegisterRoute(route core.CustomRoute, msgs map[uint16][]uint16) (result string, err string)
- func (this *CustomRouteComp) RegisterRouteFunc(route core.CustomRoute, ...)
- func (this *CustomRouteComp) Start() (err error)
- type Gate
- func (this *Gate) CloseAgent(sId string) (result string, err string)
- func (this *Gate) Connect(a IAgent)
- func (this *Gate) DisConnect(a IAgent)
- func (this *Gate) GetLocalRouteMgrComp() ILocalRouteMgrComp
- func (this *Gate) GetOptions() (options IOptions)
- func (this *Gate) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error)
- func (this *Gate) OnInstallComp()
- func (this *Gate) OnRoute(a IAgent, msg proto.IMessage) (code core.ErrorCode, err error)
- func (this *Gate) RegisterLocalRoute(comId uint16, ...)
- func (this *Gate) RegisterRemoteRoute(comId uint16, sId, sType string) (result string, err string)
- func (this *Gate) SendMsg(sId string, msg proto.IMessage) (result int, err string)
- func (this *Gate) SendMsgByBroadcast(msg proto.IMessage) (result int, err string)
- func (this *Gate) SendMsgByGroup(aIds []string, msg proto.IMessage) (result []string, err string)
- func (this *Gate) UnRegisterLocalRoute(comId uint16, ...)
- func (this *Gate) UnRegisterRemoteRoute(comId uint16, sType, sId string)
- type IAgent
- type IAgentMgrComp
- type IConn
- type ICustomRouteComp
- type IGateModule
- type ILocalRouteMgrComp
- type IOptions
- type IRemoteRouteMgrComp
- type LocalRoute
- type LocalRouteMgrComp
- func (this *LocalRouteMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, ...) (err error)
- func (this *LocalRouteMgrComp) OnRoute(agent IAgent, msg proto.IMessage) (code core.ErrorCode, err error)
- func (this *LocalRouteMgrComp) RegisterRoute(comId uint16, ...)
- func (this *LocalRouteMgrComp) SetNewSession(...)
- func (this *LocalRouteMgrComp) UnRegisterRoute(comId uint16, ...)
- type LocalSession
- func (this *LocalSession) Close() (err error)
- func (this *LocalSession) GetGateId() string
- func (this *LocalSession) GetGateServerId() string
- func (this *LocalSession) GetIP() string
- func (this *LocalSession) GetSessionId() string
- func (this *LocalSession) SendMsg(comdId uint16, msgId uint16, msg interface{}) (err error)
- func (this *LocalSession) UpDateMap(data map[string]interface{}) (err error)
- type Options
- func (this *Options) GetTcpAddr() string
- func (this *Options) GetWSAddr() string
- func (this *Options) GetWSCertFile() string
- func (this *Options) GetWSHeartbeat() time.Duration
- func (this *Options) GetWSKeyFile() string
- func (this *Options) GetWSOuttime() time.Duration
- func (this *Options) LoadConfig(settings map[string]interface{}) (err error)
- type RemoteRoute
- type RemoteRouteMgrComp
- func (this *RemoteRouteMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, ...) (err error)
- func (this *RemoteRouteMgrComp) OnRoute(agent IAgent, msg proto.IMessage) (code core.ErrorCode, err error)
- func (this *RemoteRouteMgrComp) RegisterRoute(comId uint16, sId, sType string) (result string, err string)
- func (this *RemoteRouteMgrComp) SetNewSession(...)
- func (this *RemoteRouteMgrComp) Start() (err error)
- func (this *RemoteRouteMgrComp) UnRegisterRoute(comId uint16, sType, sId string)
- type RemoteSession
- func (this *RemoteSession) Close() (err error)
- func (this *RemoteSession) GetGateId() string
- func (this *RemoteSession) GetGateServerId() string
- func (this *RemoteSession) GetIP() string
- func (this *RemoteSession) GetSessionId() string
- func (this *RemoteSession) SendMsg(comdId uint16, msgId uint16, msg interface{}) (err error)
- func (this *RemoteSession) UpDateMap(data map[string]interface{}) (err error)
- type SessionData
- type TcpConn
- func (this *TcpConn) Close()
- func (this *TcpConn) Init(conn net.Conn)
- func (this *TcpConn) LocalAddr() net.Addr
- func (this *TcpConn) Read(b []byte) (int, error)
- func (this *TcpConn) RemoteAddr() net.Addr
- func (this *TcpConn) SetDeadline(t time.Time) error
- func (this *TcpConn) SetReadDeadline(t time.Time) error
- func (this *TcpConn) SetWriteDeadline(t time.Time) error
- func (this *TcpConn) Write(b []byte) (n int, err error)
- type TcpServerComp
- type WSHandler
- type WsConn
- func (this *WsConn) Close()
- func (this *WsConn) Init(conn *websocket.Conn, heartbeat time.Duration)
- func (this *WsConn) LocalAddr() net.Addr
- func (this *WsConn) Read(p []byte) (int, error)
- func (this *WsConn) RemoteAddr() net.Addr
- func (this *WsConn) SetDeadline(t time.Time) error
- func (this *WsConn) SetReadDeadline(t time.Time) error
- func (this *WsConn) SetWriteDeadline(t time.Time) error
- func (this *WsConn) Write(b []byte) (n int, err error)
- type WsServerComp
Constants ¶
View Source
const ( Rpc_GateRouteRegister core.Rpc_Key = "Rpc_GateRouteRegister" //网关路由注册 Rpc_GateCustomRouteRegister core.Rpc_Key = "Rpc_GateCustomRouteRegister" //自定义网关路由注册 Rpc_GateRoute core.Rpc_Key = "Rpc_GateRoute" //网关路由 Rpc_GateAgentsIsKeep core.Rpc_Key = "Rpc_GateAgentsIsKeep" //校验代理是否还在 RPC_GateAgentBuild core.Rpc_Key = "RPC_GateAgentBuild" //代理绑定 RPC_GateAgentUnBuild core.Rpc_Key = "RPC_GateAgentUnBuild" //代理解绑 RPC_GateSendMsg core.Rpc_Key = "RPC_GateSendMsg" //代理发送消息 RPC_GateSendMsgByGroup core.Rpc_Key = "RPC_GateSendMsgByGroup" //代理群发消息 RPC_GateSendMsgByBroadcast core.Rpc_Key = "RPC_GateSendMsgByBroadcast" //代理广播消息 RPC_GateAgentClose core.Rpc_Key = "RPC_GateAgentClose" //代理关闭 )
Variables ¶
This section is empty.
Functions ¶
func NewLocalSession ¶
func NewLocalSession(module IGateModule, data map[string]interface{}) (s core.IUserSession, err error)
func NewRemoteSession ¶
func NewRemoteSession(service base.IClusterService, data map[string]interface{}) (s core.IUserSession, err error)
Types ¶
type AgentBase ¶
type AgentBase struct { Module IGateModule Agent IAgent Conn IConn Isclose bool // contains filtered or unexported fields }
远程链接代理
type AgentMgrComp ¶
type AgentMgrComp struct { cbase.ModuleCompBase Agents *container.BeeMap }
func (*AgentMgrComp) Close ¶
func (this *AgentMgrComp) Close(aId string) (result string, err string)
func (*AgentMgrComp) Connect ¶
func (this *AgentMgrComp) Connect(a IAgent)
func (*AgentMgrComp) Destroy ¶
func (this *AgentMgrComp) Destroy() (err error)
func (*AgentMgrComp) DisConnect ¶
func (this *AgentMgrComp) DisConnect(a IAgent)
func (*AgentMgrComp) Init ¶
func (this *AgentMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error)
func (*AgentMgrComp) SendMsgByBroadcast ¶
func (this *AgentMgrComp) SendMsgByBroadcast(msg proto.IMessage) (result int, err string)
func (*AgentMgrComp) SendMsgByGroup ¶
type CustomRouteComp ¶
type CustomRouteComp struct { cbase.ModuleCompBase // contains filtered or unexported fields }
自定义网关组件 特殊消息转发可以在自定义网关内实现与注册
func (*CustomRouteComp) Init ¶
func (this *CustomRouteComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error)
func (*CustomRouteComp) RegisterRoute ¶
func (this *CustomRouteComp) RegisterRoute(route core.CustomRoute, msgs map[uint16][]uint16) (result string, err string)
添加自定义网关组注册接口
func (*CustomRouteComp) RegisterRouteFunc ¶
func (this *CustomRouteComp) RegisterRouteFunc(route core.CustomRoute, f func(a IAgent, msg proto.IMessage) (code core.ErrorCode, err error))
添加自定义网关组注册接口
func (*CustomRouteComp) Start ¶
func (this *CustomRouteComp) Start() (err error)
type Gate ¶
type Gate struct { cbase.ModuleBase CustomRouteComp ICustomRouteComp LocalRouteMgrComp ILocalRouteMgrComp RemoteRouteMgrComp IRemoteRouteMgrComp AgentMgrComp IAgentMgrComp // contains filtered or unexported fields }
func (*Gate) CloseAgent ¶
主动关闭代理
func (*Gate) GetLocalRouteMgrComp ¶
func (this *Gate) GetLocalRouteMgrComp() ILocalRouteMgrComp
func (*Gate) GetOptions ¶
func (*Gate) OnInstallComp ¶
func (this *Gate) OnInstallComp()
func (*Gate) RegisterLocalRoute ¶
func (*Gate) RegisterRemoteRoute ¶
需重构处理 内部函数为重构代码d
func (*Gate) SendMsgByBroadcast ¶
广播代理消息
func (*Gate) SendMsgByGroup ¶
群发代理消息
func (*Gate) UnRegisterLocalRoute ¶
func (*Gate) UnRegisterRemoteRoute ¶
type IAgent ¶
type IAgent interface { Id() string IP() string GetSessionData() map[string]interface{} OnInit(gate IGateModule, coon IConn, agent IAgent) (err error) WriteMsg(msg proto.IMessage) (err error) OnRecover(msg proto.IMessage) RevNum() int64 SendNum() int64 IsClosed() bool OnRun() OnClose() //主动关闭接口 Destory() //关闭销毁 }
type IAgentMgrComp ¶
type IAgentMgrComp interface { core.IModuleComp Connect(a IAgent) DisConnect(a IAgent) SendMsg(aId string, msg proto.IMessage) (result int, err string) //发送消息到用户 SendMsgByGroup(aIds []string, msg proto.IMessage) (result []string, err string) //发送消息到用户组 SendMsgByBroadcast(msg proto.IMessage) (result int, err string) //发送消息到全服 Close(aId string) (result string, err string) }
type IConn ¶
type IConn interface { Read(b []byte) (n int, err error) Write(b []byte) (n int, err error) RemoteAddr() net.Addr Close() }
func NewTcpConn ¶
type ICustomRouteComp ¶
type IGateModule ¶
type IGateModule interface { core.IModule GetOptions() (options IOptions) GetLocalRouteMgrComp() ILocalRouteMgrComp RegisterRemoteRoute(comId uint16, sId, sType string) (result string, err string) UnRegisterRemoteRoute(comId uint16, sType, sId string) RegisterLocalRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string)) UnRegisterLocalRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string)) OnRoute(a IAgent, msg proto.IMessage) (core.ErrorCode, error) Connect(a IAgent) DisConnect(a IAgent) CloseAgent(sId string) (result string, err string) SendMsg(sId string, msg proto.IMessage) (result int, err string) //发送消息到用户 SendMsgByGroup(aIds []string, msg proto.IMessage) (result []string, err string) //发送消息到用户组 SendMsgByBroadcast(msg proto.IMessage) (result int, err string) //发送消息到全服 }
type ILocalRouteMgrComp ¶
type ILocalRouteMgrComp interface { core.IModuleComp SetNewSession(f func(module IGateModule, data map[string]interface{}) (s core.IUserSession, err error)) RegisterRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string)) UnRegisterRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string)) OnRoute(agent IAgent, msg proto.IMessage) (code core.ErrorCode, err error) }
type IRemoteRouteMgrComp ¶
type IRemoteRouteMgrComp interface { core.IModuleComp SetNewSession(f func(service base.IClusterService, data map[string]interface{}) (s core.IUserSession, err error)) RegisterRoute(comId uint16, sId, sType string) (result string, err string) UnRegisterRoute(comId uint16, sType, sId string) OnRoute(agent IAgent, msg proto.IMessage) (code core.ErrorCode, err error) }
type LocalRoute ¶
type LocalRoute struct { Module IGateModule ComId uint16 // contains filtered or unexported fields }
func NewLocalRoute ¶
func NewLocalRoute(module IGateModule, comId uint16, sf func(module IGateModule, data map[string]interface{}) (s core.IUserSession, err error), f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string)) *LocalRoute
type LocalRouteMgrComp ¶
type LocalRouteMgrComp struct { cbase.ModuleCompBase NewSession func(module IGateModule, data map[string]interface{}) (s core.IUserSession, err error) // contains filtered or unexported fields }
func (*LocalRouteMgrComp) Init ¶
func (this *LocalRouteMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error)
func (*LocalRouteMgrComp) RegisterRoute ¶
func (this *LocalRouteMgrComp) RegisterRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string))
func (*LocalRouteMgrComp) SetNewSession ¶
func (this *LocalRouteMgrComp) SetNewSession(f func(module IGateModule, data map[string]interface{}) (s core.IUserSession, err error))
func (*LocalRouteMgrComp) UnRegisterRoute ¶
func (this *LocalRouteMgrComp) UnRegisterRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code core.ErrorCode, err string))
type LocalSession ¶
type LocalSession struct {
// contains filtered or unexported fields
}
func (*LocalSession) Close ¶
func (this *LocalSession) Close() (err error)
func (*LocalSession) GetGateId ¶
func (this *LocalSession) GetGateId() string
func (*LocalSession) GetGateServerId ¶
func (this *LocalSession) GetGateServerId() string
func (*LocalSession) GetIP ¶
func (this *LocalSession) GetIP() string
func (*LocalSession) GetSessionId ¶
func (this *LocalSession) GetSessionId() string
func (*LocalSession) SendMsg ¶
func (this *LocalSession) SendMsg(comdId uint16, msgId uint16, msg interface{}) (err error)
func (*LocalSession) UpDateMap ¶
func (this *LocalSession) UpDateMap(data map[string]interface{}) (err error)
type Options ¶
type Options struct { TcpAddr string WSAddr string WSOuttime int WSHeartbeat int WSCertFile string WSKeyFile string }
func (*Options) GetTcpAddr ¶
func (*Options) GetWSCertFile ¶
func (*Options) GetWSHeartbeat ¶
func (*Options) GetWSKeyFile ¶
func (*Options) GetWSOuttime ¶
func (*Options) LoadConfig ¶
type RemoteRoute ¶
type RemoteRoute struct { Service base.IClusterService ComId uint16 ServiceType string // contains filtered or unexported fields }
func NewRemoteRoute ¶
func NewRemoteRoute(service base.IClusterService, comId uint16, f func(service base.IClusterService, data map[string]interface{}) (s core.IUserSession, err error), sNode registry.ServiceNode) *RemoteRoute
func (*RemoteRoute) Count ¶
func (this *RemoteRoute) Count() int32
func (*RemoteRoute) RegisterRoute ¶
func (this *RemoteRoute) RegisterRoute(sNode registry.ServiceNode) (err error)
注册远程路由
type RemoteRouteMgrComp ¶
type RemoteRouteMgrComp struct { cbase.ModuleCompBase NewSession func(service base.IClusterService, data map[string]interface{}) (s core.IUserSession, err error) // contains filtered or unexported fields }
func (*RemoteRouteMgrComp) Init ¶
func (this *RemoteRouteMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error)
func (*RemoteRouteMgrComp) RegisterRoute ¶
func (this *RemoteRouteMgrComp) RegisterRoute(comId uint16, sId, sType string) (result string, err string)
func (*RemoteRouteMgrComp) SetNewSession ¶
func (this *RemoteRouteMgrComp) SetNewSession(f func(service base.IClusterService, data map[string]interface{}) (s core.IUserSession, err error))
func (*RemoteRouteMgrComp) Start ¶
func (this *RemoteRouteMgrComp) Start() (err error)
func (*RemoteRouteMgrComp) UnRegisterRoute ¶
func (this *RemoteRouteMgrComp) UnRegisterRoute(comId uint16, sType, sId string)
type RemoteSession ¶
type RemoteSession struct {
// contains filtered or unexported fields
}
func (*RemoteSession) Close ¶
func (this *RemoteSession) Close() (err error)
func (*RemoteSession) GetGateId ¶
func (this *RemoteSession) GetGateId() string
func (*RemoteSession) GetGateServerId ¶
func (this *RemoteSession) GetGateServerId() string
func (*RemoteSession) GetIP ¶
func (this *RemoteSession) GetIP() string
func (*RemoteSession) GetSessionId ¶
func (this *RemoteSession) GetSessionId() string
func (*RemoteSession) SendMsg ¶
func (this *RemoteSession) SendMsg(comdId uint16, msgId uint16, msg interface{}) (err error)
func (*RemoteSession) UpDateMap ¶
func (this *RemoteSession) UpDateMap(data map[string]interface{}) (err error)
type SessionData ¶
type TcpConn ¶
func (*TcpConn) RemoteAddr ¶
type TcpServerComp ¶
type TcpServerComp struct { cbase.ModuleCompBase NewTcpAgent func(gate IGateModule, coon IConn) (IAgent, error) // contains filtered or unexported fields }
func (*TcpServerComp) Destroy ¶
func (this *TcpServerComp) Destroy() (err error)
func (*TcpServerComp) Init ¶
func (this *TcpServerComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error)
func (*TcpServerComp) Start ¶
func (this *TcpServerComp) Start() (err error)
type WsConn ¶
type WsConn struct {
// contains filtered or unexported fields
}
func (*WsConn) RemoteAddr ¶
type WsServerComp ¶
type WsServerComp struct { cbase.ModuleCompBase NewWsAgent func(gate IGateModule, coon IConn) (IAgent, error) // contains filtered or unexported fields }
func (*WsServerComp) Destroy ¶
func (this *WsServerComp) Destroy() (err error)
func (*WsServerComp) Init ¶
func (this *WsServerComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error)
func (*WsServerComp) Start ¶
func (this *WsServerComp) Start() (err error)
Click to show internal directories.
Click to hide internal directories.