Beispiel #1
0
 private Task RunReceiveAsync(ClientWebSocket client, TaskCompletionSource <bool> readySignal, CancellationToken cancelToken)
 {
     return(Task.Run(async() =>
     {
         while (true)
         {
             cancelToken.ThrowIfCancellationRequested();
             try
             {
                 await ReceiveAsync(client, readySignal, cancelToken).ConfigureAwait(false);
             }
             catch (SerializationException ex)
             {
                 DeserializationError?.Invoke(ex);
             }
         }
     }));
 }
Beispiel #2
0
 private Task RunReceiveAsync(ClientWebSocket client, TaskCompletionSource <bool> readySignal, CancellationToken cancelToken)
 {
     return(Task.Run(async() =>
     {
         while (true)
         {
             cancelToken.ThrowIfCancellationRequested();
             try
             {
                 await ReceiveAsync(client, readySignal, cancelToken).ConfigureAwait(false);
             }
             catch (WumpusRpcException ex) when(ex.Code == 4005)  // Unknown id
             {
                 // Ignore for now - this should be sent through to the promise that cause the error
             }
             catch (SerializationException ex)
             {
                 DeserializationError?.Invoke(ex);
             }
         }
     }));
 }
 protected virtual void OnDeserializationError(object error)
 {
     DeserializationError?.Invoke(this, error);
 }