示例#1
0
        private async Task OpenTwinSenderLinkAsync(AmqpIotSession amqpIotSession, string correlationIdSuffix, CancellationToken cancellationToken)
        {
            if (_twinSendingLink == null || _twinSendingLink.IsClosing())
            {
                _twinSendingLink?.SafeClose();

                _twinSendingLink = await amqpIotSession
                                   .OpenTwinSenderLinkAsync(_deviceIdentity, correlationIdSuffix, cancellationToken)
                                   .ConfigureAwait(false);

                if (_twinSenderLinkDisconnected == null)
                {
                    _twinSenderLinkDisconnected = (obj, arg) =>
                    {
                        amqpIotSession.SafeClose();
                    };
                }

                _twinSendingLink.Closed += _twinSenderLinkDisconnected;

                if (Logging.IsEnabled)
                {
                    Logging.Associate(this, _twinSendingLink, nameof(_twinSendingLink));
                }
            }
        }
示例#2
0
        private async Task OpenTwinSenderLinkAsync(AmqpIotSession amqpIotSession, string correlationIdSuffix, TimeSpan timeout)
        {
            if (_twinSendingLink == null || _twinSendingLink.IsClosing())
            {
                _twinSendingLink?.SafeClose();

                _twinSendingLink = await amqpIotSession
                                   .OpenTwinSenderLinkAsync(_deviceIdentity, correlationIdSuffix, timeout)
                                   .ConfigureAwait(false);

                _twinSendingLink.Closed += (obj, arg) =>
                {
                    amqpIotSession.SafeClose();
                };
                Logging.Associate(this, _twinSendingLink, nameof(_twinSendingLink));
            }
        }