Exemple #1
0
 public void Send(RpcPayload payload)
 {
     if (!_runCts.IsCancellationRequested)
     {
         _sendQueue?.Add(payload);
     }
 }
Exemple #2
0
 private void HandleEvent(RpcPayload evnt, TaskCompletionSource <bool> readySignal)
 {
     if (evnt.Event == RpcEvent.Error)
     {
         var data = evnt.Data as ErrorEvent;
         throw new WumpusRpcException(data.Code, data.Message);
     }
     switch (evnt.Command)
     {
     case RpcCommand.Authenticate:
         readySignal.SetResult(true);
         break;
     }
 }
Exemple #3
0
        private async Task SendAsync(ClientWebSocket client, CancellationToken cancelToken, RpcPayload payload)
        {
            payload.Nonce = Guid.NewGuid();
            var writer = JsonSerializer.Write(payload);
            await client.SendAsync(writer.AsSegment(), WebSocketMessageType.Text, true, cancelToken);

            SentPayload?.Invoke(payload, new PayloadInfo(writer.Length, writer.Length));
        }