Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Get = definePlugin.Get
Get 获取插件
View Source
var Name = definePlugin.Name
Name 插件名称
View Source
var TryGet = definePlugin.TryGet
TryGet 尝试获取插件
Functions ¶
This section is empty.
Types ¶
type Gate ¶
type Gate interface { SessionManager GroupManager // Broadcast 广播数据 Broadcast(data []byte) error // Multicast 组播数据 Multicast(groupId string, data []byte) error // Unicast 单播数据 Unicast(sessionId string, data []byte) error }
Gate 网关
type Group ¶
type Group interface { // GetId 获取会话组Id GetId() string // RangeSessions 遍历组内所有会话 RangeSessions(fun func(session Session) bool) // CountSessions 统计组内所有会话数量 CountSessions() int }
Group 客户端会话组
type GroupManager ¶
type GroupManager interface { // RangeGroups 遍历所有组 RangeGroups(fun func(group Group) bool) // CountGroups 统计所有会话组数量 CountGroups() int }
GroupManager 会话组管理器
type RecvDataHandler ¶
type RecvEventHandler ¶
type Session ¶
type Session interface { context.Context fmt.Stringer // GetId 获取会话Id GetId() string // GetToken 获取token GetToken() string // GetState 获取会话状态 GetState() SessionState // GetGroups 获取所属的会话组Id GetGroups() []string // GetListenAddr 获取监听地址 GetListenAddr() net.Addr // GetClientAddr 获取客户端地址 GetClientAddr() net.Addr // SendData 发送数据 SendData(data []byte, sequenced bool) error // SendEvent 发送自定义事件 SendEvent(event protocol.Event[transport.Msg]) error // RecvDataChan 接收数据的chan RecvDataChan() <-chan RecvData // RecvEventChan 接收自定义事件的chan RecvEventChan() <-chan RecvEvent // Close 关闭 Close(err error) }
Session 客户端会话
type SessionManager ¶
type SessionManager interface { // RangeSessions 遍历所有会话 RangeSessions(fun func(session Session) bool) // CountSessions 统计所有会话数量 CountSessions() int }
SessionManager 会话管理器
type SessionSetting ¶
type SessionSetting interface { // InitStateChangedHandlers 设置接收会话状态变化的处理器 InitStateChangedHandlers(handlers []StateChangedHandler) error // InitRecvDataHandlers 设置接收数据的处理器 InitRecvDataHandlers(handlers []RecvDataHandler) error // InitRecvEventHandlers 设置接收自定义事件的处理器 InitRecvEventHandlers(handlers []RecvEventHandler) error // InitRecvDataChanSize 设置接收数据的chan的大小,<=0表示不使用chan InitRecvDataChanSize(size int) error // InitRecvEventSize 设置自定义事件的chan的大小,<=0表示不使用chan InitRecvEventSize(size int) error }
SessionSetting 会话设置接口(在会话状态为握手中时可用)
type SessionState ¶
type SessionState int32
SessionState 客户端会话状态
const ( SessionState_Birth SessionState = iota // 出生 SessionState_Handshake // 与客户端握手中 SessionState_Active // 活跃,客户端已连接 SessionState_Inactive // 不活跃,客户端已断连,等待重连恢复中 SessionState_Death // 已过期 )
type StateChangedHandler ¶
type StateChangedHandler = func(session Session, old, new SessionState) // 会话状态变化的处理器
Source Files ¶
Click to show internal directories.
Click to hide internal directories.