public async Task ConnectAsync(CoapTransportLayerConnectOptions connectOptions, CancellationToken cancellationToken) { try { _logger.Information(nameof(CoapTransportLayerAdapter), $"Connecting with '{connectOptions.EndPoint}'..."); await _transportLayer.ConnectAsync(connectOptions, cancellationToken).ConfigureAwait(false); } catch (Exception exception) { throw new CoapCommunicationException("Error while connecting with CoAP server.", exception); } }
Task DeregisterObservation(CoapMessage message) { var emptyResponse = new CoapMessage { Type = CoapMessageType.Reset, Code = CoapMessageCodes.Empty, Id = message.Id }; _logger.Information(nameof(CoapClient), "Received unobserved message. Sending empty response to deregister."); return(_client.SendAsync(emptyResponse, CancellationToken.None)); }
async Task DeregisterObservation(CoapMessage message) { var emptyResponse = new CoapMessage { Type = CoapMessageType.Reset, Code = CoapMessageCodes.Empty, Id = message.Id }; await _lowLevelClient.SendAsync(emptyResponse, CancellationToken.None).ConfigureAwait(false); _logger.Information(nameof(CoapClient), "Received unobserved message. Sending empty response to deregister."); }
public async Task ConnectAsync(CoapTransportLayerConnectOptions connectOptions, CancellationToken cancellationToken) { if (connectOptions == null) { throw new ArgumentNullException(nameof(connectOptions)); } cancellationToken.ThrowIfCancellationRequested(); try { _logger.Information(nameof(CoapTransportLayerAdapter), $"Connecting with '{connectOptions.EndPoint}'..."); await _transportLayer.ConnectAsync(connectOptions, cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) { throw; } catch (Exception exception) { throw new CoapCommunicationException("Error while connecting with CoAP server.", exception); } }