transport

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 6 Imported by: 10

Documentation

Index

Constants

View Source
const (
	Bind        = 1
	Unbind      = 2
	Push        = 3
	Multicast   = 4
	Broadcast   = 5
	Trigger     = 6
	Deliver     = 7
	Disconnect  = 8
	GetID       = 9
	GetIP       = 10
	Stat        = 11
	IsOnline    = 12
	BlockConn   = 13
	ReleaseConn = 14
	Ping        = 15
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchPushArg added in v0.0.23

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

type BatchPushArgs added in v0.0.23

type BatchPushArgs struct {
	BatchPushArgs []*BatchPushArg
}

type DeliverArgs

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

type DisconnectHandler added in v0.0.23

type DisconnectHandler func(target string)

type GateClient

type GateClient interface {
	// Ping ping测试消息
	Ping(ctx context.Context, message string) (reply string, err error)
	// 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)
	// Stat 统计会话总数
	Stat(ctx context.Context, kind session.Kind) (total int64, miss bool, err error)
	// IsOnline 检测是否在线
	IsOnline(ctx context.Context, kind session.Kind, target int64) (isOnline, miss bool, err error)
	// GetID 检测是否在线
	GetID(ctx context.Context, kind session.Kind, target int64) (id int64, 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)
	BlockConn(ctx context.Context, onid string, nnid string, targets uint64) (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)
	// IsOnline 检测是否在线
	IsOnline(ctx context.Context, kind session.Kind, target int64) (isOnline bool, err error)
	// GetID 获取conn的id
	GetID(ctx context.Context, kind session.Kind, target int64) (id int64, 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)
	// Disconnect 断开连接
	Disconnect(ctx context.Context, kind session.Kind, target int64, isForce bool) error
	// Stat 统计会话总数
	Stat(ctx context.Context, kind session.Kind) (total int64, err error)
	// Block
	Block(ctx context.Context, oNid string, nNid string, targets uint64)
	// Release
	Release(ctx context.Context, targets uint64)
}

type Message

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

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 ReceiveHandler added in v0.0.23

type ReceiveHandler func(route uint16, msg []byte) (reply interface{}, 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 Transporter

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

type TriggerArgs

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

Directories

Path Synopsis
gnet module
grpc module
rpcx module

Jump to

Keyboard shortcuts

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