Beispiel #1
0
 public async Task InvokeClientMethodToAllAsync(string methodName, params object[] arguments)
 {
     foreach (var pair in WebSocketConnectionManager.GetAll())
     {
         try
         {
             if (pair.Value.State == WebSocketState.Open)
             {
                 await InvokeClientMethodAsync(pair.Key, methodName, arguments).ConfigureAwait(false);
             }
         }
         catch (WebSocketException e)
         {
             if (e.WebSocketErrorCode == WebSocketError.ConnectionClosedPrematurely)
             {
                 await OnDisconnected(pair.Value);
             }
         }
     }
 }
Beispiel #2
0
 public async Task SendMessageToAllAsync(Message message)
 {
     foreach (var pair in WebSocketConnectionManager.GetAll())
     {
         try
         {
             if (pair.Value.State == WebSocketState.Open)
             {
                 await SendMessageAsync(pair.Value, message).ConfigureAwait(false);
             }
         }
         catch (WebSocketException e)
         {
             if (e.WebSocketErrorCode == WebSocketError.ConnectionClosedPrematurely)
             {
                 await OnDisconnected(pair.Value);
             }
         }
     }
 }