public sealed class RpcRouterEncodes remote calls, and refuses the ones that arrive.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Nothing a packet says about who sent it is believed. The sender is what the session says it is — the connection the bytes arrived on — and it is what ownership and the rate limit are checked against. A call carries what it is about and what to do, never who is asking, because who is asking is exactly the field a client would fill in.
Every inbound call is checked before anything runs: the indices must name a call in the manifest, the direction must be one this peer accepts, the object must be one that is registered, ownership must hold if the call asks for it, the connection must be inside its rate limit, and the arguments must decode and leave nothing behind. Six checks, each of which is a counter, which is what the diagnostics panel will show.
Fields and properties (21)
public RpcRole RoleWhat this peer is.
public NetworkOwnership OwnershipWho owns what.
public NetworkRulesRegistry RulesWho is allowed to do what.
public int RegisteredCountHow many objects have handlers registered.
public BandwidthLedger? LedgerWhere the bandwidth went, or null to not ask.
public long AcceptedCountCalls that ran.
public long RefusedByManifestCountCalls refused because the indices name nothing in the manifest.
public long RefusedByDirectionCountCalls refused because they were going the wrong way for this peer.
public long RefusedByUnknownObjectCountCalls refused because the object they are about is not registered here.
public long RefusedByOwnershipCountCalls refused because the caller was not allowed to make them — by the object's rules, or by the call's own RequireOwnership, whichever was stricter.
public long RefusedByRateLimitCountCalls refused because the caller is making too many.
public long RefusedByArgumentsCountCalls refused because the arguments did not decode, or left bits behind.
public long RefusedToSendCountCalls this peer declined to send, because it is not the side that may send them.
public TimeSpan DefaultTimeoutHow long an awaited call waits before giving up, unless told otherwise.
public int PendingCallCountHow many awaited calls are outstanding.
public long AnsweredCountAwaited calls that were answered.
public long TimedOutCountAwaited calls that nobody answered in time.
public long UnmatchedReplyCountReplies that arrived addressed to no outstanding call.
public bool IsServerWhether this peer runs server calls.
public bool IsClientWhether this peer runs client calls.
public long RefusedByRulesCountRequests refused because the rules did not allow them.
Methods (14)
public RpcRouter(RpcManifest manifest, IRpcTransport transport, RpcRole role, NetworkOwnership? ownership = null, IRpcObservers? observers = null, RpcLimits? limits = null, NetworkRulesRegistry? rules = null, int maxPayloadBytes = 1200)Creates a router.
public void Register(NetworkId id, IRpcInvoker invoker)Attaches an object's handlers, so calls about it can be dispatched.
public bool Unregister(NetworkId id, IRpcInvoker invoker)Detaches one type's handlers from an object.
public bool TryTransferOwnership(NetworkId id, PlayerId requester, PlayerId newOwner)Hands an object to somebody else, if the asker is allowed to.
public void Forget(NetworkId id)Detaches everything about an object, because it was destroyed.
public void Advance(TimeSpan elapsed)Refills the rate limiters.
public Task<T> CallAsync<T>(RpcMethod method, NetworkId target, RpcArguments? arguments, RpcResult<T> result, TimeSpan? timeout = null)Asks a question and waits for the answer.
public bool Reply(in RpcContext context, RpcArguments? result)Answers a call that was waiting for one.
public bool ReceiveReply(PlayerId from, ReadOnlySpan<byte> payload)Takes a reply off the wire and completes whatever was waiting for it.
public int CancelPending(PlayerId player)Fails everything waiting on a peer that has gone.
public void CancelAllPending()Fails every outstanding call, for a session that is stopping.
public BitWriter BeginCall(RpcMethod method, NetworkId target)Starts encoding a call, with its header already written.
public bool EndCall(RpcMethod method, NetworkId target, ref BitWriter writer)Sends an encoded call to whoever it is for.
public bool Receive(PlayerId from, ReadOnlySpan<byte> payload)Takes a call off the wire, checks it, and runs it.
Used by (21)
- ArenaMultiplayer
- AvatarControllerMultiplayer
- GameClientMultiplayer
- GameServerMultiplayer
- RpcSendersMultiplayer
- AnsweringVixen.Net.Tests
- AwaitableRpcTestsVixen.Net.Tests
- CounterVixen.Net.Tests
- GeneratedTurretVixen.Net.Generators.Tests
- IRpcObjectVixen.Net
- LoopbackVixen.Net.Tests
- NetworkMetricsVixen.Net
- NetworkRulesTestsVixen.Net.Tests
- PayloadRecorderVixen.Net.Tests
- RpcGeneratorTestsVixen.Net.Generators.Tests
- RpcOverSessionTestsVixen.Net.Tests
- RpcRouterTargetVixen.Net.Fuzz
- RpcSendersVixen.Net.Generators.Tests
- RpcTestsVixen.Net.Tests
- SendersVixen.Net.Tests
- TurretVixen.Net.Tests