public static PacketDto Create(Guid sender, Guid receiver, MessageDto message, bool reliable) => new PacketDto { // Id = Guid.NewGuid(), Id = GuidSource.Next(), SenderId = sender, ReceiverId = receiver, Message = message, Flags = reliable ? PacketFlags.Reliable : PacketFlags.None };
public Task SendUnreliableAsync(Guid destination, MessageDto message) { return unicaster.SendUnreliableAsync(destination, message); }
public Task SendMessageBroadcastAsync(MessageDto message) { return testTransportFactory.SendMessageBroadcastAsync(message); }
public Task SendReliableAsync(Guid destination, MessageDto message) { return testTransportFactory.SendMessageReliableAsync(destination, message); }
private async Task DispatchOnAllTransports(MessageDto message) { foreach (var transport in transports) { await transport.InboundMessageDispatcher.DispatchAsync(message).ConfigureAwait(false); } }
public async Task SendMessageUnreliableAsync(Guid destination, MessageDto message) { await DispatchOnAllTransports(message).ConfigureAwait(false); }
public async Task SendMessageBroadcastAsync(MessageDto message) { await DispatchOnAllTransports(message).ConfigureAwait(false); }
public Task SendMessageBroadcastAsync(MessageDto message) { return Task.WhenAll( tcpRoutingContextContainer.Enumerate().Select( clientRoutingContext => clientRoutingContext.SendBroadcastAsync(message))); }
private async Task SendHelperAsync(Guid destination, MessageDto message) { Debug( $"Sending to {destination.ToString("n").Substring(0, 6)} message {message}. " + Environment.NewLine + $"clientIdentity matches destination: {remoteIdentity.Matches(destination, IdentityMatchingScope.Broadcast)}"); if (!isHandshakeComplete || !remoteIdentity.Matches(destination, IdentityMatchingScope.Broadcast)) { return; } var completionLatch = new AsyncLatch(); sendCompletionLatchByMessage.AddOrThrow(message, completionLatch); outboundMessageQueue.Enqueue(message); outboundMessageSignal.Release(); Debug($"Awaiting completion for send to {destination.ToString("n").Substring(0, 6)} message {message}."); await completionLatch.WaitAsync().ConfigureAwait(false); sendCompletionLatchByMessage.RemoveOrThrow(message, completionLatch); Debug($"Completed send to {destination.ToString("n").Substring(0, 6)} message {message}."); }
public Task SendReliableAsync(Guid destination, MessageDto message) { return SendHelperAsync(destination, message); }
public Task SendBroadcastAsync(MessageDto message) { return SendHelperAsync(Guid.Empty, message); }