transport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GateClient

type GateClient interface {
	// Bind 绑定用户与连接
	Bind(ctx context.Context, cid, uid int64) (miss bool, err error)
	// Unbind 解绑用户与连接
	Unbind(ctx context.Context, uid int64) (miss bool, err error)
	// GetIP 获取客户端IP
	GetIP(ctx context.Context, kind session.Kind, target int64) (ip string, miss bool, err error)
	// Disconnect 断开连接
	Disconnect(ctx context.Context, kind session.Kind, target int64, isForce bool) (miss bool, err error)
	// Push 推送消息
	Push(ctx context.Context, kind session.Kind, target int64, message *Message) (miss bool, err error)
	// Multicast 推送组播消息
	Multicast(ctx context.Context, kind session.Kind, targets []int64, message *Message) (total int64, err error)
	// Broadcast 推送广播消息
	Broadcast(ctx context.Context, kind session.Kind, message *Message) (total int64, err error)
}

type GateProvider

type GateProvider interface {
	// Session 获取会话
	Session(kind session.Kind, target int64) (*session.Session, error)
	// Bind 绑定用户与网关间的关系
	Bind(ctx context.Context, uid int64) error
	// Unbind 解绑用户与网关间的关系
	Unbind(ctx context.Context, uid int64) error
	// Push 发送消息(异步)
	Push(kind session.Kind, target int64, msg []byte, msgType ...int) error
	// Multicast 推送组播消息(异步)
	Multicast(kind session.Kind, targets []int64, msg []byte, msgType ...int) (n int, err error)
	// Broadcast 推送广播消息(异步)
	Broadcast(kind session.Kind, msg []byte, msgType ...int) (n int, err error)
}

type Message

type Message struct {
	Seq    int32  // 序列号
	Route  int32  // 路由
	Buffer []byte // 消息内容
}

type NodeClient

type NodeClient interface {
	// Trigger 触发事件
	Trigger(ctx context.Context, event cluster.Event, gid string, uid int64) (miss bool, err error)
	// Deliver 投递消息
	Deliver(ctx context.Context, gid, nid string, cid, uid int64, message *Message) (miss bool, err error)
}

type NodeProvider

type NodeProvider interface {
	// LocateNode 定位用户所在节点
	LocateNode(ctx context.Context, uid int64) (nid string, miss bool, err error)
	// CheckRouteStateful 检测某个路由是否为有状态路由
	CheckRouteStateful(route int32) (stateful bool, exist bool)
	// Trigger 触发事件
	Trigger(event cluster.Event, gid string, uid int64)
	// Deliver 投递消息
	Deliver(gid, nid string, cid, uid int64, message *Message)
}

type Server

type Server interface {
	// Addr 监听地址
	Addr() string
	// Scheme 协议
	Scheme() string
	// Endpoint 服务端口
	Endpoint() *endpoint.Endpoint
	// Start 启动服务器
	Start() error
	// Stop 停止服务器
	Stop() error
}

type Transporter

type Transporter interface {
	// NewGateServer 新建网关服务器
	NewGateServer(provider GateProvider) (Server, error)
	// NewNodeServer 新建节点服务器
	NewNodeServer(provider NodeProvider) (Server, error)
	// NewGateClient 新建网关客户端
	NewGateClient(ep *router.Endpoint) (GateClient, error)
	// NewNodeClient 新建节点客户端
	NewNodeClient(ep *router.Endpoint) (NodeClient, error)
}

Directories

Path Synopsis
rpcx module

Jump to

Keyboard shortcuts

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