Ejemplo n.º 1
0
        public Task ConnectAsync(CoapTransportLayerConnectOptions options, CancellationToken cancellationToken)
        {
            _connectOptions = options ?? throw new ArgumentNullException(nameof(options));

            Dispose();

            _udpClient = new UdpClient(0, options.EndPoint.AddressFamily);

            return(Task.FromResult(0));
        }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
        public async Task ConnectAsync(CoapTransportLayerConnectOptions options, CancellationToken cancellationToken)
        {
            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            Dispose();

            _tcpClient = new TcpClient();
            using (cancellationToken.Register(Dispose))
            {
                await _tcpClient.ConnectAsync(options.EndPoint.Address, options.EndPoint.Port).ConfigureAwait(false);

                _networkStream = _tcpClient.GetStream();
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
 public Task ConnectAsync(CoapTransportLayerConnectOptions connectOptions, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }