link

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastArgs

type BroadcastArgs = cluster.BroadcastArgs

type DeliverArgs

type DeliverArgs struct {
	NID     string      // 接收节点。存在接收节点时,消息会直接投递给接收节点;不存在接收节点时,系统定位用户所在节点,然后投递。
	CID     int64       // 连接ID
	UID     int64       // 用户ID
	Route   int32       // 路由
	Message interface{} // 消息
}

type DisconnectArgs

type DisconnectArgs = cluster.DisconnectArgs

type GateLinker added in v2.1.0

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

func NewGateLinker added in v2.1.0

func NewGateLinker(ctx context.Context, opts *Options) *GateLinker

func (*GateLinker) Ask added in v2.1.0

func (l *GateLinker) Ask(ctx context.Context, gid string, uid int64) (string, bool, error)

Ask 检测用户是否在给定的网关上

func (*GateLinker) Bind added in v2.1.0

func (l *GateLinker) Bind(ctx context.Context, gid string, cid, uid int64) error

Bind 绑定网关

func (*GateLinker) Broadcast added in v2.1.0

func (l *GateLinker) Broadcast(ctx context.Context, args *BroadcastArgs) error

Broadcast 推送广播消息

func (*GateLinker) Disconnect added in v2.1.0

func (l *GateLinker) Disconnect(ctx context.Context, args *DisconnectArgs) error

Disconnect 断开连接

func (*GateLinker) FetchGateList added in v2.1.0

func (l *GateLinker) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)

FetchGateList 拉取网关列表

func (*GateLinker) GetIP added in v2.1.0

func (l *GateLinker) GetIP(ctx context.Context, args *GetIPArgs) (string, error)

GetIP 获取客户端IP

func (*GateLinker) GetState added in v2.1.0

func (l *GateLinker) GetState(ctx context.Context, gid string) (cluster.State, error)

GetState 获取网关状态

func (*GateLinker) Has added in v2.2.0

func (l *GateLinker) Has(gid string) bool

Has 检测是否存在某个网关

func (*GateLinker) IsOnline added in v2.1.0

func (l *GateLinker) IsOnline(ctx context.Context, args *IsOnlineArgs) (bool, error)

IsOnline 检测是否在线

func (*GateLinker) Locate added in v2.1.0

func (l *GateLinker) Locate(ctx context.Context, uid int64) (string, error)

Locate 定位用户所在网关

func (*GateLinker) Multicast added in v2.1.0

func (l *GateLinker) Multicast(ctx context.Context, args *MulticastArgs) error

Multicast 推送组播消息

func (*GateLinker) PackBuffer added in v2.2.0

func (l *GateLinker) PackBuffer(message interface{}, encrypt bool) ([]byte, error)

PackBuffer 消息转buffer

func (*GateLinker) PackMessage added in v2.2.0

func (l *GateLinker) PackMessage(message *Message, encrypt bool) (buffer.Buffer, error)

PackMessage 打包消息

func (*GateLinker) Push added in v2.1.0

func (l *GateLinker) Push(ctx context.Context, args *PushArgs) error

Push 推送消息

func (*GateLinker) SetState added in v2.1.0

func (l *GateLinker) SetState(ctx context.Context, gid string, state cluster.State) error

SetState 设置网关状态

func (*GateLinker) Stat added in v2.1.0

func (l *GateLinker) Stat(ctx context.Context, kind session.Kind) (int64, error)

Stat 统计会话总数

func (*GateLinker) Unbind added in v2.1.0

func (l *GateLinker) Unbind(ctx context.Context, uid int64) error

Unbind 解绑网关

func (*GateLinker) WatchClusterInstance added in v2.1.0

func (l *GateLinker) WatchClusterInstance()

WatchClusterInstance 监听集群实例

func (*GateLinker) WatchUserLocate added in v2.1.0

func (l *GateLinker) WatchUserLocate()

WatchUserLocate 监听用户定位

type GetIPArgs

type GetIPArgs = cluster.GetIPArgs

type IsOnlineArgs added in v2.1.0

type IsOnlineArgs = cluster.IsOnlineArgs

type Message

type Message = cluster.Message

type MulticastArgs

type MulticastArgs = cluster.MulticastArgs

type NodeLinker added in v2.1.0

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

func NewNodeLinker added in v2.1.0

func NewNodeLinker(ctx context.Context, opts *Options) *NodeLinker

func (*NodeLinker) Ask added in v2.1.0

func (l *NodeLinker) Ask(ctx context.Context, uid int64, name, nid string) (string, bool, error)

Ask 检测用户是否在给定的节点上

func (*NodeLinker) Bind added in v2.1.0

func (l *NodeLinker) Bind(ctx context.Context, uid int64, name, nid string) error

Bind 绑定节点 单个用户可以绑定到多个节点服务器上,相同名称的节点服务器只能绑定一个,多次绑定会到相同名称的节点服务器会覆盖之前的绑定。 绑定操作会通过发布订阅方式同步到网关服务器和其他相关节点服务器上。

func (*NodeLinker) Deliver added in v2.1.0

func (l *NodeLinker) Deliver(ctx context.Context, args *DeliverArgs) error

Deliver 投递消息给节点处理

func (*NodeLinker) FetchNodeList added in v2.1.0

func (l *NodeLinker) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)

FetchNodeList 拉取节点列表

func (*NodeLinker) GetState added in v2.1.0

func (l *NodeLinker) GetState(ctx context.Context, nid string) (cluster.State, error)

GetState 获取节点状态

func (*NodeLinker) Has added in v2.2.0

func (l *NodeLinker) Has(nid string) bool

Has 检测是否存在某个节点

func (*NodeLinker) Locate added in v2.1.0

func (l *NodeLinker) Locate(ctx context.Context, uid int64, name string) (string, error)

Locate 定位用户所在节点

func (*NodeLinker) SetState added in v2.1.0

func (l *NodeLinker) SetState(ctx context.Context, nid string, state cluster.State) error

SetState 设置节点状态

func (*NodeLinker) Trigger added in v2.1.0

func (l *NodeLinker) Trigger(ctx context.Context, args *TriggerArgs) error

Trigger 触发事件

func (*NodeLinker) Unbind added in v2.1.0

func (l *NodeLinker) Unbind(ctx context.Context, uid int64, name, nid string) error

Unbind 解绑节点 解绑时会对对应名称的节点服务器进行解绑,解绑时会对解绑节点ID进行校验,不匹配则解绑失败。 解绑操作会通过发布订阅方式同步到网关服务器和其他相关节点服务器上。

func (*NodeLinker) WatchClusterInstance added in v2.1.0

func (l *NodeLinker) WatchClusterInstance()

WatchClusterInstance 监听集群实例

func (*NodeLinker) WatchUserLocate added in v2.1.0

func (l *NodeLinker) WatchUserLocate()

WatchUserLocate 监听用户定位

type Options

type Options struct {
	InsID           string                     // 实例ID
	InsKind         cluster.Kind               // 实例类型
	Codec           encoding.Codec             // 编解码器
	Locator         locate.Locator             // 定位器
	Registry        registry.Registry          // 注册器
	Encryptor       crypto.Encryptor           // 加密器
	BalanceStrategy dispatcher.BalanceStrategy // 负载均衡策略
}

type PushArgs

type PushArgs = cluster.PushArgs

type TriggerArgs

type TriggerArgs struct {
	Event cluster.Event // 事件
	CID   int64         // 连接ID
	UID   int64         // 用户ID
}

Jump to

Keyboard shortcuts

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