Exemple #1
0
        internal async Task <IAmqpAuthenticationRefresher> CreateRefresherAsync(DeviceIdentity deviceIdentity, TimeSpan timeout)
        {
            if (_amqpConnection.IsClosing())
            {
                throw AmqpIoTExceptionAdapter.RESOUCE_DISCONNECTED_EXCEPTION;
            }
            try
            {
                IAmqpAuthenticationRefresher amqpAuthenticator = new AmqpAuthenticationRefresher(deviceIdentity, _amqpIoTCbsLink);
                await amqpAuthenticator.InitLoopAsync(timeout).ConfigureAwait(false);

                return(amqpAuthenticator);
            }
            catch (Exception e) when(!e.IsFatal())
            {
                Exception ex = AmqpIoTExceptionAdapter.ConvertToIoTHubException(e, _amqpConnection);

                if (ReferenceEquals(e, ex))
                {
                    throw;
                }
                else
                {
                    throw ex;
                }
            }
        }
        internal async Task <IAmqpAuthenticationRefresher> CreateRefresherAsync(DeviceIdentity deviceIdentity, TimeSpan timeout)
        {
            if (_amqpConnection.IsClosing())
            {
                throw new IotHubCommunicationException("Amqp connection is disconnected.");
            }
            try
            {
                IAmqpAuthenticationRefresher amqpAuthenticator = new AmqpAuthenticationRefresher(deviceIdentity, _amqpIotCbsLink);
                await amqpAuthenticator.InitLoopAsync(timeout).ConfigureAwait(false);

                return(amqpAuthenticator);
            }
            catch (Exception e) when(!e.IsFatal())
            {
                Exception ex = AmqpIotExceptionAdapter.ConvertToIotHubException(e, _amqpConnection);

                if (ReferenceEquals(e, ex))
                {
                    throw;
                }
                else
                {
                    throw ex;
                }
            }
        }