Class RpcGate

Namespace
Unity.Multiplayer.Core

The engine-free checks every generated RPC stub runs before calling the game's handler: on the server, a ToServerAttribute call must come from the entity's owner (when required) and be within the sender's rate; on a client, a server-to-client call must come from the server.

public sealed class RpcGate
Inheritance
RpcGate
Inherited Members

Remarks

One gate per server session; the adapter keeps it with the session and forgets a sender when it leaves.

Constructors

RpcGate()

A gate with its own, empty rate limiter.

public RpcGate()

RpcGate(RpcRateLimiter)

A gate over limiter.

public RpcGate(RpcRateLimiter limiter)

Parameters

limiter RpcRateLimiter

Exceptions

ArgumentNullException

limiter is null.

Properties

Limiter

The per-sender buckets behind RateLimit.

public RpcRateLimiter Limiter { get; }

Property Value

RpcRateLimiter

Methods

CheckFromServer(ulong)

Decides one incoming server-to-client call: it must come from the server.

public static RpcVerdict CheckFromServer(ulong sender)

Parameters

sender ulong

Returns

RpcVerdict

CheckToServer(string, bool, ulong, ulong, bool, int, int, double)

Decides one incoming ToServerAttribute call.

public RpcVerdict CheckToServer(string rpc, bool isServer, ulong sender, ulong owner, bool requireOwnership, int rateLimit, int burst, double now)

Parameters

rpc string

The RPC key (declaring type and method name).

isServer bool

True when this process is the server.

sender ulong

The calling client id.

owner ulong

The entity's owner client id.

requireOwnership bool

The RPC's RequireOwnership.

rateLimit int

The RPC's RateLimit; 0 for none.

burst int

The RPC's Burst; 0 for one second's worth.

now double

The current time in seconds.

Returns

RpcVerdict

Remarks

The server itself (ServerClientId, which on a host is also the host's own player) passes the ownership check: the authority may always act. Ownership is checked before the rate, so a refused non-owner spends none of the owner's budget.

Clear()

Forgets everything (the session ended).

public void Clear()

Forget(ulong)

Forgets a sender's rate buckets (it disconnected).

public void Forget(ulong sender)

Parameters

sender ulong