Пример #1
0
 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);
     }
 }
Пример #2
0
        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));
        }
Пример #3
0
        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.");
        }
Пример #4
0
        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);
            }
        }