transport

package
v0.0.0-...-e849032 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeliverArgs

type DeliverArgs struct {
	GID     string
	NID     string
	CID     int64
	UID     int64
	Message *packet.Message
}

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)
	// Push 推送消息
	Push(ctx context.Context, kind session.Kind, target int64, message *packet.Message) (miss bool, err error)
	// Multicast 推送组播消息
	Multicast(ctx context.Context, kind session.Kind, targets []int64, message *packet.Message) (total int64, err error)
	// Broadcast 推送广播消息
	Broadcast(ctx context.Context, kind session.Kind, message *packet.Message) (total int64, err error)
	// Stat 统计会话总数
	Stat(ctx context.Context, kind session.Kind) (total int64, err error)
	// Disconnect 断开连接
	Disconnect(ctx context.Context, kind session.Kind, target int64, isForce bool) (miss bool, err error)
}

type GateProvider

type GateProvider interface {
	// Bind 绑定用户与网关间的关系
	Bind(ctx context.Context, cid, uid int64) error
	// Unbind 解绑用户与网关间的关系
	Unbind(ctx context.Context, uid int64) error
	// GetIP 获取客户端IP地址
	GetIP(ctx context.Context, kind session.Kind, target int64) (ip string, err error)
	// Push 发送消息(异步)
	Push(ctx context.Context, kind session.Kind, target int64, message *packet.Message) error
	// Multicast 推送组播消息(异步)
	Multicast(ctx context.Context, kind session.Kind, targets []int64, message *packet.Message) (total int64, err error)
	// Broadcast 推送广播消息(异步)
	Broadcast(ctx context.Context, kind session.Kind, message *packet.Message) (total int64, err error)
	// Stat 统计会话总数
	Stat(ctx context.Context, kind session.Kind) (total int64, err error)
	// Disconnect 断开连接
	Disconnect(ctx context.Context, kind session.Kind, target int64, isForce bool) error
}

type NewServiceClientFunc

type NewServiceClientFunc func(target string) (ServiceClient, error)

type NodeClient

type NodeClient interface {
	// Trigger 触发事件
	Trigger(ctx context.Context, args *TriggerArgs) (miss bool, err error)
	// Deliver 投递消息
	Deliver(ctx context.Context, args *DeliverArgs) (miss bool, err error)
}

type NodeProvider

type NodeProvider interface {
	// Trigger 触发事件
	Trigger(ctx context.Context, args *TriggerArgs) (miss bool, err error)
	// Deliver 投递消息
	Deliver(ctx context.Context, args *DeliverArgs) (miss bool, err error)
}

type Server

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

type ServiceClient

type ServiceClient interface {
	// Call 调用服务方法
	Call(ctx context.Context, service, method string, args interface{}, reply interface{}, opts ...interface{}) error
	// Client 获取内部客户端
	Client() interface{}
}

type Transporter

type Transporter interface {
	// SetDefaultDiscovery 设置默认的服务发现组件
	SetDefaultDiscovery(discovery registry.Discovery)
	// NewGateServer 新建网关服务器
	NewGateServer(provider GateProvider) (Server, error)
	// NewNodeServer 新建节点服务器
	NewNodeServer(provider NodeProvider) (Server, error)
	// NewServiceServer 新建微服务服务器
	NewServiceServer() (Server, error)
	// NewGateClient 新建网关客户端
	NewGateClient(ep *endpoint.Endpoint) (GateClient, error)
	// NewNodeClient 新建节点客户端
	NewNodeClient(ep *endpoint.Endpoint) (NodeClient, error)
	// NewServiceClient 新建微服务客户端
	NewServiceClient(target string) (ServiceClient, error)
}

type TriggerArgs

type TriggerArgs struct {
	Event cluster.Event
	GID   string
	CID   int64
	UID   int64
}

Jump to

Keyboard shortcuts

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