Documentation ¶
Index ¶
- Variables
- type BroadcastArgs
- type DeliverArgs
- type DisconnectArgs
- type EventHandler
- type GetIPArgs
- type Message
- type MulticastArgs
- type Node
- type Option
- func WithCodec(codec encoding.Codec) Option
- func WithContext(ctx context.Context) Option
- func WithDecryptor(decryptor crypto.Decryptor) Option
- func WithEncryptor(encryptor crypto.Encryptor) Option
- func WithID(id string) Option
- func WithLocator(locator locate.Locator) Option
- func WithName(name string) Option
- func WithRegistry(r registry.Registry) Option
- func WithTimeout(timeout time.Duration) Option
- func WithTransporter(transporter transport.Transporter) Option
- type Proxy
- type PushArgs
- type Request
- type RouteHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidGID = errors.New("invalid gate id") ErrInvalidNID = errors.New("invalid node id") ErrInvalidSessionKind = errors.New("invalid session kind") ErrNotFoundUserSource = errors.New("not found user source") ErrReceiveTargetEmpty = errors.New("the receive target is empty") ErrUnableLocateSource = errors.New("unable to locate source") )
Functions ¶
This section is empty.
Types ¶
type BroadcastArgs ¶
type DeliverArgs ¶
type DisconnectArgs ¶
type EventHandler ¶
type MulticastArgs ¶
type Option ¶
type Option func(o *options)
func WithTransporter ¶
func WithTransporter(transporter transport.Transporter) Option
WithTransporter 设置消息传输器
type Proxy ¶
type Proxy interface { // GetID 获取当前节点ID GetID() string // AddRouteHandler 添加路由处理器 AddRouteHandler(route int32, stateful bool, handler RouteHandler) // SetDefaultRouteHandler 设置默认路由处理器,所有未注册的路由均走默认路由处理器 SetDefaultRouteHandler(handler RouteHandler) // AddEventListener 添加事件监听器 AddEventListener(event cluster.Event, handler EventHandler) // BindGate 绑定网关 BindGate(ctx context.Context, gid string, cid, uid int64) error // UnbindGate 绑定网关 UnbindGate(ctx context.Context, uid int64) error // BindNode 绑定节点 BindNode(ctx context.Context, uid int64, nid ...string) error // UnbindNode 解绑节点 UnbindNode(ctx context.Context, uid int64, nid ...string) error // LocateGate 定位用户所在网关 LocateGate(ctx context.Context, uid int64) (string, error) // LocateNode 定位用户所在节点 LocateNode(ctx context.Context, uid int64) (string, error) // FetchGateList 拉取网关列表 FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error) // FetchNodeList 拉取节点列表 FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error) // GetIP 获取客户端IP GetIP(ctx context.Context, args *GetIPArgs) (string, error) // Push 推送消息 Push(ctx context.Context, args *PushArgs) error // Response 响应消息 Response(ctx context.Context, req Request, message interface{}) error // Multicast 推送组播消息 Multicast(ctx context.Context, args *MulticastArgs) (int64, error) // Broadcast 推送广播消息 Broadcast(ctx context.Context, args *BroadcastArgs) (int64, error) // Disconnect 断开连接 Disconnect(ctx context.Context, args *DisconnectArgs) error // Deliver 投递消息给节点处理 Deliver(ctx context.Context, args *DeliverArgs) error }
type Request ¶
type Request interface { // GID 获取来源网关ID GID() string // NID 获取来源节点ID NID() string // CID 获取来源连接ID CID() int64 // UID 获取来源用户ID UID() int64 // Seq 获取消息序列号 Seq() int32 // Route 获取路由 Route() int32 // Data 获取数据 Data() interface{} // Parse 解析请求 Parse(v interface{}) error // Context 获取上线文 Context() context.Context // GetIP 获取IP地址 GetIP() (string, error) // Response 响应请求 Response(message interface{}) error // BindGate 绑定网关 BindGate(uid int64) error // UnbindGate 解绑网关 UnbindGate() error // BindNode 绑定节点 BindNode() error // UnbindNode 解绑节点 UnbindNode() error // Disconnect 断开连接 Disconnect(isForce ...bool) error }
type RouteHandler ¶
type RouteHandler func(req Request)
Click to show internal directories.
Click to hide internal directories.