public AmqpServiceClient(IotHubConnectionString iotHubConnectionString, bool useWebSocketOnly, ServiceClientTransportSettings transportSettings, ServiceClientOptions options)
        {
            var iotHubConnection = new IotHubConnection(iotHubConnectionString, AccessRights.ServiceConnect, useWebSocketOnly, transportSettings);

            Connection                = iotHubConnection;
            OpenTimeout               = IotHubConnection.DefaultOpenTimeout;
            OperationTimeout          = IotHubConnection.DefaultOperationTimeout;
            _sendingPath              = "/messages/deviceBound";
            _faultTolerantSendingLink = new FaultTolerantAmqpObject <SendingAmqpLink>(CreateSendingLinkAsync, Connection.CloseLink);
            _feedbackReceiver         = new AmqpFeedbackReceiver(Connection);
            _fileNotificationReceiver = new AmqpFileNotificationReceiver(Connection);
            _iotHubName               = iotHubConnectionString.IotHubName;
            _clientOptions            = options;
            _httpClientHelper         = new HttpClientHelper(
                iotHubConnectionString.HttpsEndpoint,
                iotHubConnectionString,
                ExceptionHandlingHelper.GetDefaultErrorMapping(),
                s_defaultOperationTimeout,
                transportSettings.HttpProxy);

            // Set the trace provider for the AMQP library.
            AmqpTrace.Provider = new AmqpTransportLog();
        }
        /// <summary>
        /// Create an instance of ServiceClient from the specified IoT Hub connection string using specified Transport Type and transport settings.
        /// </summary>
        /// <param name="connectionString">Connection string for the IoT Hub.</param>
        /// <param name="transportType">The <see cref="TransportType"/> used (Amqp or Amqp_WebSocket_Only).</param>
        /// <param name="transportSettings">Specifies the AMQP and HTTP proxy settings for Service Client.</param>
        /// <param name="options">The <see cref="ServiceClientOptions"/> that allow configuration of the service client instance during initialization.</param>
        /// <returns>An instance of ServiceClient.</returns>
        public static ServiceClient CreateFromConnectionString(string connectionString, TransportType transportType, ServiceClientTransportSettings transportSettings, ServiceClientOptions options = default)
        {
            if (transportSettings == null)
            {
                throw new ArgumentNullException(nameof(transportSettings));
            }

            var  iotHubConnectionString = IotHubConnectionString.Parse(connectionString);
            bool useWebSocketOnly       = transportType == TransportType.Amqp_WebSocket_Only;
            var  serviceClient          = new AmqpServiceClient(iotHubConnectionString, useWebSocketOnly, transportSettings, options);

            return(serviceClient);
        }
 /// <summary>
 /// Create an instance of ServiceClient from the specified IoT Hub connection string using specified Transport Type.
 /// </summary>
 /// <param name="connectionString">Connection string for the IoT Hub.</param>
 /// <param name="transportType">The <see cref="TransportType"/> used (Amqp or Amqp_WebSocket_Only).</param>
 /// <param name="options">The <see cref="ServiceClientOptions"/> that allow configuration of the service client instance during initialization.</param>
 /// <returns>An instance of ServiceClient.</returns>
 public static ServiceClient CreateFromConnectionString(string connectionString, TransportType transportType, ServiceClientOptions options = default)
 {
     return(CreateFromConnectionString(connectionString, transportType, new ServiceClientTransportSettings(), options));
 }
 /// <summary>
 /// Create an instance of ServiceClient from the specified IoT Hub connection string.
 /// </summary>
 /// <param name="connectionString">Connection string for the IoT Hub.</param>
 /// <param name="options">The <see cref="ServiceClientOptions"/> that allow configuration of the service client instance during initialization.</param>
 /// <returns>An instance of ServiceClient.</returns>
 public static ServiceClient CreateFromConnectionString(string connectionString, ServiceClientOptions options = default)
 {
     return(CreateFromConnectionString(connectionString, TransportType.Amqp, options));
 }