public Task SendAsync(TMessage message) { return(_baseTransport.SendAsync(new JsonMessage() { Json = JsonConvert.SerializeObject(message, _serializerSettings) })); }
private async Task SendAsync(Message message, CancellationToken ct) { TaskUtilities.AssertIsOnBackgroundThread(); Log.Request(message.ToString(), _rLoopDepth); try { await _transport.SendAsync(message, 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); } catch (MessageTransportException ex) { throw new RHostDisconnectedException(ex.Message, ex); } }
private async Task SendAsync(JToken token, CancellationToken ct) { TaskUtilities.AssertIsOnBackgroundThread(); var json = JsonConvert.SerializeObject(token); _log.Request(json, _rLoopDepth); try { await _transport.SendAsync(json, 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); } }