private async Task OnReceivedAsync(SendToClientInvocationMessage message) { OrleansHubLifetimeManagerLog.ReceivedFromStream(_logger, _clientStreamId); if (_connectionsById.TryGetValue(message.ConnectionId, out var connection)) { var invocationMessage = new InvocationMessage(message.MethodName, message.Args); try { await connection.WriteAsync(invocationMessage).AsTask(); } catch (Exception e) { OrleansHubLifetimeManagerLog.FailedWritingMessage(_logger, e); } } }
private async Task OnReceivedAsync(SendToAllInvocationMessage message) { OrleansHubLifetimeManagerLog.ReceivedFromStream(_logger, _clientStreamId); var invocationMessage = new InvocationMessage(message.MethodName, message.Args); var tasks = _connectionsById .Where(pair => !pair.Value.ConnectionAborted.IsCancellationRequested && !message.ExcludedConnectionIds.Contains(pair.Key)) .Select(pair => pair.Value.WriteAsync(invocationMessage).AsTask()); try { await Task.WhenAll(tasks); } catch (Exception e) { OrleansHubLifetimeManagerLog.FailedWritingMessage(_logger, e); } }