Documentation
¶
Overview ¶
Package basegate handler
Package basegate gate.Session
Index ¶
- func NewSession(data []byte) (gate.ISession, error)
- func NewSessionByMap(data map[string]any) (gate.ISession, error)
- func NewTCPConnAgent() gate.IConnAgent
- func NewWSConnAgent() gate.IConnAgent
- type Delegate
- func (this *Delegate) Connect(a gate.IConnAgent)
- func (this *Delegate) DisConnect(a gate.IConnAgent)
- func (this *Delegate) GetAgent(sessionId string) (gate.IConnAgent, error)
- func (this *Delegate) GetAgentNum() int
- func (this *Delegate) OnDestroy()
- func (this *Delegate) OnRpcBind(ctx context.Context, sessionId string, userId string) (gate.ISession, error)
- func (this *Delegate) OnRpcBroadcast(ctx context.Context, topic string, body []byte) (int64, error)
- func (this *Delegate) OnRpcClose(ctx context.Context, sessionId string) (bool, error)
- func (this *Delegate) OnRpcConnected(ctx context.Context, sessionId string) (bool, error)
- func (this *Delegate) OnRpcDel(ctx context.Context, sessionId string, key string) (gate.ISession, error)
- func (this *Delegate) OnRpcLoad(ctx context.Context, sessionId string) (gate.ISession, error)
- func (this *Delegate) OnRpcPush(ctx context.Context, sessionId string, settings map[string]string) (gate.ISession, error)
- func (this *Delegate) OnRpcSend(ctx context.Context, sessionId string, topic string, body []byte) (bool, error)
- func (this *Delegate) OnRpcSet(ctx context.Context, sessionId string, key string, value string) (gate.ISession, error)
- func (this *Delegate) OnRpcUnBind(ctx context.Context, sessionId string) (gate.ISession, error)
- type GateBase
- func (this *GateBase) GetAgentLearner() gate.IAgentLearner
- func (this *GateBase) GetDelegater() gate.IDelegater
- func (this *GateBase) GetGuestJudger() func(session gate.ISession) bool
- func (this *GateBase) GetRouteHandler() gate.RouteHandler
- func (this *GateBase) GetSendMessageHook() gate.SendMessageHook
- func (this *GateBase) GetSessionLearner() gate.ISessionLearner
- func (this *GateBase) GetShakeHandler() func(r *http.Request) error
- func (this *GateBase) GetStorageHandler() (storager gate.StorageHandler)
- func (this *GateBase) GetType() string
- func (this *GateBase) Init(subclass app.IRPCModule, settings *conf.ModuleSettings, opts ...gate.Option)
- func (this *GateBase) OnAppConfigurationLoaded()
- func (this *GateBase) OnConfChanged(settings *conf.ModuleSettings)
- func (this *GateBase) OnDestroy()
- func (this *GateBase) Options() gate.Options
- func (this *GateBase) Run(closeSig chan bool)
- func (this *GateBase) SetAgentCreater(cfunc func(netTyp string) gate.IConnAgent) error
- func (this *GateBase) SetAgentLearner(learner gate.IAgentLearner) error
- func (this *GateBase) SetGateHandler(handler gate.IDelegater) error
- func (this *GateBase) SetGuestJudger(judger func(session gate.ISession) bool) error
- func (this *GateBase) SetRouteHandler(router gate.RouteHandler) error
- func (this *GateBase) SetSendMessageHook(hook gate.SendMessageHook) error
- func (this *GateBase) SetSessionLearner(learner gate.ISessionLearner) error
- func (this *GateBase) SetShakeHandler(handler func(r *http.Request) error) error
- func (this *GateBase) SetStorageHandler(storager gate.StorageHandler) error
- func (this *GateBase) Version() string
- type SessionImp
- type TCPConnAgent
- func (this *TCPConnAgent) Close()
- func (this *TCPConnAgent) ConnTime() time.Time
- func (this *TCPConnAgent) GetError() error
- func (this *TCPConnAgent) GetSession() gate.ISession
- func (this *TCPConnAgent) Init(impl gate.IConnAgent, gt gate.IGate, conn network.Conn) error
- func (this *TCPConnAgent) IsClosed() bool
- func (this *TCPConnAgent) IsShaked() bool
- func (this *TCPConnAgent) OnClose() error
- func (this *TCPConnAgent) OnHandRecvPack(pack *gate.Pack) error
- func (this *TCPConnAgent) OnReadDecodingPack() (*gate.Pack, error)
- func (this *TCPConnAgent) OnWriteEncodingPack(pack *gate.Pack) []byte
- func (this *TCPConnAgent) RecvNum() int64
- func (this *TCPConnAgent) Run() (err error)
- func (this *TCPConnAgent) SendNum() int64
- func (this *TCPConnAgent) SendPack(pack *gate.Pack) error
- type WSConnAgent
- func (this *WSConnAgent) Close()
- func (this *WSConnAgent) ConnTime() time.Time
- func (this *WSConnAgent) GetError() error
- func (this *WSConnAgent) GetSession() gate.ISession
- func (this *WSConnAgent) Init(impl gate.IConnAgent, gt gate.IGate, conn network.Conn) error
- func (this *WSConnAgent) IsClosed() bool
- func (this *WSConnAgent) IsShaked() bool
- func (this *WSConnAgent) OnClose() error
- func (this *WSConnAgent) OnHandRecvPack(pack *gate.Pack) error
- func (this *WSConnAgent) OnReadDecodingPack() (*gate.Pack, error)
- func (this *WSConnAgent) OnWriteEncodingPack(pack *gate.Pack) []byte
- func (this *WSConnAgent) RecvNum() int64
- func (this *WSConnAgent) Run() (err error)
- func (this *WSConnAgent) SendNum() int64
- func (this *WSConnAgent) SendPack(pack *gate.Pack) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSessionByMap ¶
NewSessionByMap data可以为空则构造一个空的Session
func NewTCPConnAgent ¶
func NewTCPConnAgent() gate.IConnAgent
func NewWSConnAgent ¶
func NewWSConnAgent() gate.IConnAgent
Types ¶
type Delegate ¶
type Delegate struct {
// contains filtered or unexported fields
}
Delegate Delegate(gate.IAgentLearner,gate.IDelegater)
func (*Delegate) DisConnect ¶
func (this *Delegate) DisConnect(a gate.IConnAgent)
当连接关闭(客户端主动关闭或者异常断开)
func (*Delegate) GetAgent ¶
func (this *Delegate) GetAgent(sessionId string) (gate.IConnAgent, error)
GetAgent
func (*Delegate) OnRpcBind ¶
func (this *Delegate) OnRpcBind(ctx context.Context, sessionId string, userId string) (gate.ISession, error)
Bind the session with the the userId.
func (*Delegate) OnRpcBroadcast ¶
broadcast message to all session of the gate
func (*Delegate) OnRpcClose ¶
Proactively close the connection of session
func (*Delegate) OnRpcConnected ¶
check connect is normal for the session
func (*Delegate) OnRpcDel ¶
func (this *Delegate) OnRpcDel(ctx context.Context, sessionId string, key string) (gate.ISession, error)
Del value from the session.
func (*Delegate) OnRpcPush ¶
func (this *Delegate) OnRpcPush(ctx context.Context, sessionId string, settings map[string]string) (gate.ISession, error)
Push the session with the the userId.
func (*Delegate) OnRpcSend ¶
func (this *Delegate) OnRpcSend(ctx context.Context, sessionId string, topic string, body []byte) (bool, error)
Send message to the session.
type GateBase ¶
type GateBase struct {
module.ModuleBase
// contains filtered or unexported fields
}
func (*GateBase) GetAgentLearner ¶
func (this *GateBase) GetAgentLearner() gate.IAgentLearner
SetAgentLearner 获取客户端连接和断开的监听器(建议用 SetSessionLearner)
func (*GateBase) GetDelegater ¶
func (this *GateBase) GetDelegater() gate.IDelegater
GetDelegater 获取代理处理器
func (*GateBase) GetGuestJudger ¶
GetGuestJudger 获取是否游客的判定器
func (*GateBase) GetRouteHandler ¶
func (this *GateBase) GetRouteHandler() gate.RouteHandler
GetRouteHandler 获取路由接口
func (*GateBase) GetSendMessageHook ¶
func (this *GateBase) GetSendMessageHook() gate.SendMessageHook
GetSendMessageHook 获取发送消息时的钩子回调
func (*GateBase) GetSessionLearner ¶
func (this *GateBase) GetSessionLearner() gate.ISessionLearner
GetSessionLearner 获取客户端连接和断开的监听器
func (*GateBase) GetShakeHandler ¶
GetShakeHandler 获取建立连接时鉴权器(ws)
func (*GateBase) GetStorageHandler ¶
func (this *GateBase) GetStorageHandler() (storager gate.StorageHandler)
GetStorageHandler 获取Session信息持久化接口
func (*GateBase) Init ¶
func (this *GateBase) Init(subclass app.IRPCModule, settings *conf.ModuleSettings, opts ...gate.Option)
func (*GateBase) OnAppConfigurationLoaded ¶
func (this *GateBase) OnAppConfigurationLoaded()
func (*GateBase) OnConfChanged ¶
func (this *GateBase) OnConfChanged(settings *conf.ModuleSettings)
func (*GateBase) SetAgentCreater ¶
func (this *GateBase) SetAgentCreater(cfunc func(netTyp string) gate.IConnAgent) error
设置创建客户端Agent的函数
func (*GateBase) SetAgentLearner ¶
func (this *GateBase) SetAgentLearner(learner gate.IAgentLearner) error
SetAgentLearner 设置客户端连接和断开的监听器(内部用)
func (*GateBase) SetGateHandler ¶
func (this *GateBase) SetGateHandler(handler gate.IDelegater) error
SetGateHandler 设置代理处理器
func (*GateBase) SetGuestJudger ¶
SetGuestJudger 设置是否游客的判定器
func (*GateBase) SetRouteHandler ¶
func (this *GateBase) SetRouteHandler(router gate.RouteHandler) error
SetRouteHandler 设置路由接口
func (*GateBase) SetSendMessageHook ¶
func (this *GateBase) SetSendMessageHook(hook gate.SendMessageHook) error
SetsendMessageHook 设置发送消息时的钩子回调
func (*GateBase) SetSessionLearner ¶
func (this *GateBase) SetSessionLearner(learner gate.ISessionLearner) error
SetSessionLearner 设置客户端连接和断开的监听器
func (*GateBase) SetShakeHandler ¶
SetShakeHandler 设置建立连接时鉴权器(ws)
func (*GateBase) SetStorageHandler ¶
func (this *GateBase) SetStorageHandler(storager gate.StorageHandler) error
SetStorageHandler 设置Session信息持久化接口
type SessionImp ¶
type SessionImp struct {
IP string `msgpack:"ip,omitempty" json:"ip,omitempty"`
Network string `msgpack:"network,omitempty" json:"network,omitempty"`
UserId string `msgpack:"user_id,omitempty" json:"user_id,omitempty"`
SessionId string `msgpack:"session_id,omitempty" json:"session_id,omitempty"`
ServerId string `msgpack:"server_id,omitempty" json:"server_id,omitempty"`
TraceId string `msgpack:"trace_id,omitempty" json:"trace_id,omitempty"`
SpanId string `msgpack:"span_id,omitempty" json:"span_id,omitempty"`
Settings map[string]string `msgpack:"settings,omitempty" json:"settings,omitempty"`
}
type TCPConnAgent ¶
type TCPConnAgent struct {
// contains filtered or unexported fields
}
func (*TCPConnAgent) GetSession ¶
GetSession 管理的ClientSession
func (*TCPConnAgent) OnHandRecvPack ¶
实现如何处理收到的数据包
func (*TCPConnAgent) OnReadDecodingPack ¶
func (this *TCPConnAgent) OnReadDecodingPack() (*gate.Pack, error)
读取数据并解码出Pack
func (*TCPConnAgent) OnWriteEncodingPack ¶
OnWriteEncodingPack 处理Pack数据的编码用于发送
type WSConnAgent ¶
type WSConnAgent struct {
// contains filtered or unexported fields
}
func (*WSConnAgent) GetSession ¶
GetSession 管理的ClientSession
func (*WSConnAgent) OnHandRecvPack ¶
实现如何处理收到的数据包
func (*WSConnAgent) OnReadDecodingPack ¶
func (this *WSConnAgent) OnReadDecodingPack() (*gate.Pack, error)
读取数据并解码出Pack
func (*WSConnAgent) OnWriteEncodingPack ¶
OnWriteEncodingPack 处理Pack数据的编码用于发送