36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using FinalFactory.Rendezvous.Contracts;
|
|
|
|
namespace FinalFactory.Rendezvous.Client;
|
|
|
|
public sealed class RendezvousConnectionStartResult
|
|
{
|
|
internal RendezvousConnectionStartResult(
|
|
CreateJoinAttemptResponse? attempt,
|
|
RendezvousConnectionOutcome? outcome)
|
|
{
|
|
if ((attempt is null) == (outcome is null))
|
|
{
|
|
throw new ArgumentException(
|
|
"A connection start result requires exactly one attempt or terminal outcome.");
|
|
}
|
|
|
|
Attempt = attempt;
|
|
Outcome = outcome;
|
|
}
|
|
|
|
public CreateJoinAttemptResponse? Attempt { get; }
|
|
public RendezvousConnectionOutcome? Outcome { get; }
|
|
public bool IsReadyForTraversal => Attempt is not null;
|
|
public bool IsCompleted => Outcome is not null;
|
|
|
|
public static RendezvousConnectionStartResult ReadyForTraversal(
|
|
CreateJoinAttemptResponse attempt) => new(
|
|
attempt ?? throw new ArgumentNullException(nameof(attempt)),
|
|
null);
|
|
|
|
public static RendezvousConnectionStartResult Completed(
|
|
RendezvousConnectionOutcome outcome) => new(
|
|
null,
|
|
outcome ?? throw new ArgumentNullException(nameof(outcome)));
|
|
}
|