gate

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Rpc_GateRouteRegister core.Rpc_Key = "GateRouteRegister" //网关路由注册
	Rpc_GateRoute         core.Rpc_Key = "GateRoute"         //网关路由
	Rpc_GateAgentsIsKeep  core.Rpc_Key = "GateAgentsIsKeep"  //校验代理是否还在
	RPC_GateAgentBuild    core.Rpc_Key = "GateAgentBuild"    //代理绑定
	RPC_GateAgentUnBuild  core.Rpc_Key = "GateAgentUnBuild"  //代理解绑
	RPC_GateAgentSendMsg  core.Rpc_Key = "GateAgentSendMsg"  //代理发送消息
	RPC_GateAgentClose    core.Rpc_Key = "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
}

远程链接代理

func (*AgentBase) Destory

func (this *AgentBase) Destory()

func (*AgentBase) IP

func (this *AgentBase) IP() string

func (*AgentBase) Id

func (this *AgentBase) Id() string

func (*AgentBase) IsClosed

func (this *AgentBase) IsClosed() bool

func (*AgentBase) OnClose

func (this *AgentBase) OnClose()

func (*AgentBase) OnCloseWait

func (this *AgentBase) OnCloseWait()

func (*AgentBase) OnInit

func (this *AgentBase) OnInit(module IGateModule, coon IConn, agent IAgent) (err error)

func (*AgentBase) OnRecover

func (this *AgentBase) OnRecover(msg proto.IMessage)

func (*AgentBase) OnRun

func (this *AgentBase) OnRun()

func (*AgentBase) RevNum

func (this *AgentBase) RevNum() int64

func (*AgentBase) SendNum

func (this *AgentBase) SendNum() int64

func (*AgentBase) WriteMsg

func (this *AgentBase) WriteMsg(msg proto.IMessage) error

type AgentMgrComp

type AgentMgrComp struct {
	cbase.ModuleCompBase
	Agents *cont.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, _Settings map[string]interface{}) (err error)

func (*AgentMgrComp) SendMsg

func (this *AgentMgrComp) SendMsg(aId string, msg proto.IMessage) (result int, err string)

type Gate

type Gate struct {
	cbase.ModuleBase
}

func (*Gate) CloseAgent

func (this *Gate) CloseAgent(sId string) (result string, err string)

主动关闭代理

func (*Gate) Connect

func (this *Gate) Connect(a IAgent)

需重构处理 内部函数为重构代码 代理链接

func (*Gate) DisConnect

func (this *Gate) DisConnect(a IAgent)

代理关闭

func (*Gate) OnRoute

func (this *Gate) OnRoute(a IAgent, msg proto.IMessage) (code int, err string)

接收代理消息

func (*Gate) RegisterLocalRoute

func (this *Gate) RegisterLocalRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code int, err string))

func (*Gate) SendMsg

func (this *Gate) SendMsg(sId string, msg proto.IMessage) (result int, err string)

发送代理消息

func (*Gate) UnRegisterLocalRoute

func (this *Gate) UnRegisterLocalRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage))

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()     //主动关闭接口
	OnCloseWait() //主动关闭接口 等待链接销毁
	Destory()     //关闭销毁
}

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

func NewTcpConn(conn net.Conn) IConn

func NewWsConn

func NewWsConn(conn *websocket.Conn) IConn

type IGateModule

type IGateModule interface {
	core.IModule
	//需重构处理  内部函数为重构代码
	RegisterLocalRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code int, err string))
	UnRegisterLocalRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage))
	OnRoute(a IAgent, msg proto.IMessage) (code int, err string)
	Connect(a IAgent)
	DisConnect(a IAgent)
	CloseAgent(sId string) (result string, err string)
	SendMsg(sId string, msg proto.IMessage) (result int, err string)
}

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 int, err string)) *LocalRoute

func (*LocalRoute) OnRoute

func (this *LocalRoute) OnRoute(a IAgent, msg proto.IMessage) (code int, err string)

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, settings map[string]interface{}) (err error)

func (*LocalRouteMgrComp) OnRoute

func (this *LocalRouteMgrComp) OnRoute(agent IAgent, msg proto.IMessage) (code int, err string)

func (*LocalRouteMgrComp) RegisterRoute

func (this *LocalRouteMgrComp) RegisterRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage) (code int, err string))

func (*LocalRouteMgrComp) UnRegisterRoute

func (this *LocalRouteMgrComp) UnRegisterRoute(comId uint16, f func(session core.IUserSession, msg proto.IMessage))

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 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) OnRoute

func (this *RemoteRoute) OnRoute(a IAgent, msg proto.IMessage) (code int, err string)

func (*RemoteRoute) RegisterRoute

func (this *RemoteRoute) RegisterRoute(sNode registry.ServiceNode) (err error)

注册远程路由

func (*RemoteRoute) UnRegisterRoute

func (this *RemoteRoute) UnRegisterRoute(sId string)

注销远程路由

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, settings map[string]interface{}) (err error)

func (*RemoteRouteMgrComp) OnRoute

func (this *RemoteRouteMgrComp) OnRoute(agent IAgent, msg proto.IMessage) (code int, err string)

func (*RemoteRouteMgrComp) RegisterRoute

func (this *RemoteRouteMgrComp) RegisterRoute(comId uint16, sId string) (result string, err string)

func (*RemoteRouteMgrComp) Start

func (this *RemoteRouteMgrComp) Start() (err error)

func (*RemoteRouteMgrComp) UnRegisterRoute

func (this *RemoteRouteMgrComp) UnRegisterRoute(comId uint16, 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 SessionData struct {
	IP           string
	SessionId    string
	GateServerId string //用户所在网关服务
}

type TcpConn

type TcpConn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*TcpConn) Close

func (this *TcpConn) Close()

func (*TcpConn) Init

func (this *TcpConn) Init(conn net.Conn)

func (*TcpConn) LocalAddr

func (this *TcpConn) LocalAddr() net.Addr

func (*TcpConn) Read

func (this *TcpConn) Read(b []byte) (int, error)

func (*TcpConn) RemoteAddr

func (this *TcpConn) RemoteAddr() net.Addr

func (*TcpConn) SetDeadline

func (this *TcpConn) SetDeadline(t time.Time) error

func (*TcpConn) SetReadDeadline

func (this *TcpConn) SetReadDeadline(t time.Time) error

func (*TcpConn) SetWriteDeadline

func (this *TcpConn) SetWriteDeadline(t time.Time) error

func (*TcpConn) Write

func (this *TcpConn) Write(b []byte) (n int, err error)

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, settings map[string]interface{}) (err error)

func (*TcpServerComp) Start

func (this *TcpServerComp) Start() (err error)

type WSHandler

type WSHandler struct {
	// contains filtered or unexported fields
}

func (*WSHandler) ServeHTTP

func (handler *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WsConn

type WsConn struct {
	// contains filtered or unexported fields
}

func (*WsConn) Close

func (this *WsConn) Close()

func (*WsConn) Init

func (this *WsConn) Init(conn *websocket.Conn)

func (*WsConn) LocalAddr

func (this *WsConn) LocalAddr() net.Addr

func (*WsConn) Read

func (this *WsConn) Read(p []byte) (int, error)

func (*WsConn) RemoteAddr

func (this *WsConn) RemoteAddr() net.Addr

func (*WsConn) SetDeadline

func (this *WsConn) SetDeadline(t time.Time) error

func (*WsConn) SetReadDeadline

func (this *WsConn) SetReadDeadline(t time.Time) error

func (*WsConn) SetWriteDeadline

func (this *WsConn) SetWriteDeadline(t time.Time) error

func (*WsConn) Write

func (this *WsConn) Write(b []byte) (n int, err error)

type WsServerComp

type WsServerComp struct {
	cbase.ModuleCompBase

	CertFile string
	KeyFile  string

	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, settings map[string]interface{}) (err error)

func (*WsServerComp) Start

func (this *WsServerComp) Start() (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL