runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionExists   = errors.New("proxy connection already exists")
	ErrConnectionNotFound = errors.New("proxy connection not found")
	ErrInvalidIdentity    = errors.New("proxy identity is invalid")
	ErrUpstreamMissing    = errors.New("proxy upstream is missing")
)

Functions

This section is empty.

Types

type Delivery

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

Delivery 跟踪用于下行消息的存活传输连接。

func NewDelivery

func NewDelivery() *Delivery

NewDelivery 创建空的存活连接投递注册表。

func (*Delivery) Add

func (d *Delivery) Add(conn proxy.Connection) error

Add 按 ID 注册一个连接,并拒绝重复所有权。

func (*Delivery) Broadcast

func (d *Delivery) Broadcast(ctx context.Context, connIDs []string, msg rpc.Message) error

Broadcast 向每个连接 ID 发送同一条消息,并合并失败。

func (*Delivery) Close

func (d *Delivery) Close(ctx context.Context, connID string) error

Close 关闭并注销一个连接 ID。

func (*Delivery) Remove

func (d *Delivery) Remove(connID string) bool

Remove 注销一个连接 ID,并返回其是否存在。

func (*Delivery) Send

func (d *Delivery) Send(ctx context.Context, connID string, msg rpc.Message) error

Send 克隆并投递一条下行消息到已注册连接。

type Gateway

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

Gateway 拥有已认证客户端 Session,并转发上行消息;它不了解 Player、World、DBPlayer 或 feature Module。

func NewGateway

func NewGateway(auth proxy.Authenticator, upstream proxy.Upstream) *Gateway

NewGateway 创建带空连接索引和 UID 索引的 proxy Gateway。

func (*Gateway) Accept

func (g *Gateway) Accept(ctx context.Context, conn proxy.Connection, req proxy.AuthRequest) (Session, error)

Accept 认证并注册一个连接。

func (*Gateway) AcceptIdentity

func (g *Gateway) AcceptIdentity(conn proxy.Connection, identity proxy.Identity) (Session, error)

AcceptIdentity 直接按已认证身份注册连接。

func (*Gateway) ConnectionIDs

func (g *Gateway) ConnectionIDs(uid int64) []string

ConnectionIDs 返回 uid 当前已认证的连接 ID 列表。

func (*Gateway) Disconnect

func (g *Gateway) Disconnect(connID string) bool

Disconnect 从 Session 注册表移除一个连接。

func (*Gateway) DisconnectSession

func (g *Gateway) DisconnectSession(connID string) (Session, bool)

DisconnectSession 从 Session 注册表移除一个连接,并返回被移除的 Session。

func (*Gateway) Receive

func (g *Gateway) Receive(ctx context.Context, connID string, msg rpc.Message) error

Receive 向上游转发一条已认证客户端消息。

func (*Gateway) Session

func (g *Gateway) Session(connID string) (Session, bool)

Session 按连接 ID 返回连接级 Session 快照。

func (*Gateway) SessionsByUID

func (g *Gateway) SessionsByUID(uid int64) []Session

SessionsByUID 返回 uid 当前已认证的 Session 快照。

type RPCUpstream

type RPCUpstream struct {
	Bus rpc.Bus
}

RPCUpstream 将已认证客户端消息转发到 aifd-rpc Bus。

func NewRPCUpstream

func NewRPCUpstream(bus rpc.Bus) *RPCUpstream

NewRPCUpstream 创建使用指定 Bus 的上行转发器。

func (*RPCUpstream) Forward

func (u *RPCUpstream) Forward(ctx context.Context, env proxy.Envelope) error

Forward 将 Envelope 中的消息按 uid 投递到 RPC route。

type Session

type Session struct {
	ConnectionID string
	Identity     proxy.Identity
}

Session 是 proxy 连接级 runtime 状态。

Jump to

Keyboard shortcuts

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