public async Task ConnectAsync(CoapClientConnectOptions options, CancellationToken cancellationToken) { _connectOptions = options ?? throw new ArgumentNullException(nameof(options)); await _lowLevelClient.ConnectAsync(options, cancellationToken).ConfigureAwait(false); _cancellationToken = new CancellationTokenSource(); ParallelTask.StartLongRunning(() => ReceiveMessages(_cancellationToken.Token), _cancellationToken.Token); }
public async Task ConnectAsync(CoapClientConnectOptions options, CancellationToken cancellationToken) { if (options is null) { throw new ArgumentNullException(nameof(options)); } _connectOptions = options; _transportLayer = options.TransportLayer; await _transportLayer.ConnectAsync(options, cancellationToken).ConfigureAwait(false); }
public async Task ConnectAsync(CoapClientConnectOptions options, CancellationToken cancellationToken) { if (options is null) { throw new ArgumentNullException(nameof(options)); } _connectOptions = options; _lowLevelClient?.Dispose(); _lowLevelClient = new LowLevelCoapClient(_logger); await _lowLevelClient.ConnectAsync(options, cancellationToken).ConfigureAwait(false); _cancellationToken = new CancellationTokenSource(); ParallelTask.Run(() => ReceiveMessages(_cancellationToken.Token), _cancellationToken.Token); }