Class InMemoryJoinCodeService
- Namespace
- Unity.Multiplayer.Core
An IJoinCodeService that keeps its codes in this process: for tests, local play and as the reference behaviour the networked implementations match. Thread-safe.
public sealed class InMemoryJoinCodeService : IJoinCodeService, IDisposable
- Inheritance
-
InMemoryJoinCodeService
- Implements
- Inherited Members
Remarks
Codes never expire here; they live until RevokeAsync(JoinCode, CancellationToken).
Constructors
InMemoryJoinCodeService()
Mints DefaultDataLength-character codes from a cryptographic RNG.
public InMemoryJoinCodeService()
InMemoryJoinCodeService(int, RandomNumberGenerator)
Mints codes with dataLength data characters from rng
(a cryptographic RNG when null; the service does not dispose one it was given).
public InMemoryJoinCodeService(int dataLength, RandomNumberGenerator rng)
Parameters
dataLengthintrngRandomNumberGenerator
Exceptions
- ArgumentOutOfRangeException
dataLengthis out of range.
Properties
Count
How many codes are live.
public int Count { get; }
Property Value
Methods
Dispose()
Disposes the RNG if this service created it.
public void Dispose()
PublishAsync(JoinTarget, CancellationToken)
Publishes target and returns the code players join with.
public Task<JoinCode> PublishAsync(JoinTarget target, CancellationToken cancellationToken = default)
Parameters
targetJoinTargetcancellationTokenCancellationToken
Returns
Exceptions
- ArgumentNullException
targetis null.- NotSupportedException
This service cannot publish that Kind.
ResolveAsync(JoinCode, CancellationToken)
The target code leads to, or null when it is unknown, revoked or expired.
public Task<JoinTarget> ResolveAsync(JoinCode code, CancellationToken cancellationToken = default)
Parameters
codeJoinCodecancellationTokenCancellationToken
Returns
RevokeAsync(JoinCode, CancellationToken)
Withdraws code so it no longer resolves. True when it was live.
public Task<bool> RevokeAsync(JoinCode code, CancellationToken cancellationToken = default)
Parameters
codeJoinCodecancellationTokenCancellationToken