7 private readonly Option<EosP2PSocket> eosSocket;
8 private readonly Option<SteamListenSocket> steamSocket;
12 Option<EosP2PSocket> eosSocket,
13 Option<SteamListenSocket> steamSocket) :
16 this.eosSocket = eosSocket;
17 this.steamSocket = steamSocket;
24 if (eosP2PSocketResult.TryUnwrapFailure(out var eosError)
25 && steamP2PSocketResult.TryUnwrapFailure(out var steamError))
27 return Result.Failure(
new Error(eosError, steamError));
31 eosP2PSocketResult.TryUnwrapSuccess(out var eosP2PSocket)
34 steamP2PSocketResult.TryUnwrapSuccess(out var steamP2PSocket)
41 if (eosSocket.TryUnwrap(out var eosP2PSocket)) { eosP2PSocket.ProcessIncomingMessages(); }
42 if (steamSocket.TryUnwrap(out var steamP2PSocket)) { steamP2PSocket.ProcessIncomingMessages(); }
47 return endpoint
switch
49 EosP2PEndpoint eosP2PEndpoint when eosSocket.TryUnwrap(out var eosP2PSocket)
50 => eosP2PSocket.SendMessage(eosP2PEndpoint, outMsg, deliveryMethod),
51 SteamP2PEndpoint steamP2PEndpoint when steamSocket.TryUnwrap(out var steamP2PSocket)
52 => steamP2PSocket.SendMessage(steamP2PEndpoint, outMsg, deliveryMethod),
63 if (eosSocket.TryUnwrap(out var eosP2PSocket))
65 eosP2PSocket.CloseConnection(eosP2PEndpoint);
68 case SteamP2PEndpoint steamP2PEndpoint:
69 if (steamSocket.TryUnwrap(out var steamP2PSocket))
71 steamP2PSocket.CloseConnection(steamP2PEndpoint);
79 if (eosSocket.TryUnwrap(out var eosP2PSocket)) { eosP2PSocket.Dispose(); }
80 if (steamSocket.TryUnwrap(out var steamP2PSocket)) { steamP2PSocket.Dispose(); }
override void ProcessIncomingMessages()
static Result< P2PSocket, Error > Create(Callbacks callbacks)
override void CloseConnection(P2PEndpoint endpoint)
override bool SendMessage(P2PEndpoint endpoint, IWriteMessage outMsg, DeliveryMethod deliveryMethod)
static Result< P2PSocket, Error > Create(Callbacks callbacks)
readonly record struct Error(ImmutableArray<(ErrorCode Code, string AdditionalInfo)> CodesAndInfo)
readonly record struct Callbacks(Predicate< P2PEndpoint > OnIncomingConnection, Action< P2PEndpoint, PeerDisconnectPacket > OnConnectionClosed, Action< P2PEndpoint, IReadMessage > OnData)
readonly Callbacks callbacks
static Result< P2PSocket, Error > Create(Callbacks callbacks)