private async Task <Message> ReceiveMessageAsync(CancellationToken ct) { var sb = new StringBuilder(); string json; try { json = await _transport.ReceiveAsync(ct); } catch (MessageTransportException ex) when(ct.IsCancellationRequested) { // Network errors during cancellation are expected, but should not be exposed to clients. throw new OperationCanceledException(new OperationCanceledException().Message, ex); } _log.Response(json, _rLoopDepth); var token = JToken.Parse(json); var value = token as JValue; if (value != null && value.Value == null) { return(null); } return(new Message(token)); }
private async Task <Message> ReceiveMessageAsync(CancellationToken ct) { Message message; try { message = await _transport.ReceiveAsync(ct); } catch (MessageTransportException ex) when(ct.IsCancellationRequested) { // Network errors during cancellation are expected, but should not be exposed to clients. throw new OperationCanceledException(new OperationCanceledException().Message, ex); } _log.Response(message.ToString(), _rLoopDepth); return(message); }