public async Task<SendingAmqpLink> CreateSendingLinkAsync(string path, IotHubConnectionString connectionString, TimeSpan timeout) { this.OnCreateSendingLink(connectionString); var timeoutHelper = new TimeoutHelper(timeout); AmqpSession session; if (!this.FaultTolerantSession.TryGetOpenedObject(out session)) { session = await this.FaultTolerantSession.GetOrCreateAsync(timeoutHelper.RemainingTime()); } var linkAddress = this.BuildLinkAddress(connectionString, path); var linkSettings = new AmqpLinkSettings() { Role = false, InitialDeliveryCount = 0, Target = new Target() { Address = linkAddress.AbsoluteUri }, SndSettleMode = null, // SenderSettleMode.Unsettled (null as it is the default and to avoid bytes on the wire) RcvSettleMode = null, // (byte)ReceiverSettleMode.First (null as it is the default and to avoid bytes on the wire) LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debugging }; SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime()); var link = new SendingAmqpLink(linkSettings); link.AttachTo(session); var audience = this.BuildAudience(connectionString, path); await this.OpenLinkAsync(link, connectionString, audience, timeoutHelper.RemainingTime()); return link; }
protected override void OnCreateReceivingLink(IotHubConnectionString connectionString) { if (connectionString.SharedAccessKeyName != null) { throw new ArgumentException("Must provide a device-scope connection string", "connectionString"); } }
public async Task<ReceivingAmqpLink> CreateReceivingLinkAsync(string path, IotHubConnectionString connectionString, TimeSpan timeout, uint prefetchCount) { this.OnCreateReceivingLink(connectionString); var timeoutHelper = new TimeoutHelper(timeout); AmqpSession session; if (!this.FaultTolerantSession.TryGetOpenedObject(out session)) { session = await this.FaultTolerantSession.GetOrCreateAsync(timeoutHelper.RemainingTime()); } var linkAddress = this.BuildLinkAddress(connectionString, path); var linkSettings = new AmqpLinkSettings() { Role = true, TotalLinkCredit = prefetchCount, AutoSendFlow = prefetchCount > 0, Source = new Source() { Address = linkAddress.AbsoluteUri }, SndSettleMode = null, // SenderSettleMode.Unsettled (null as it is the default and to avoid bytes on the wire) RcvSettleMode = (byte)ReceiverSettleMode.Second, LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debuggin }; SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime()); var link = new ReceivingAmqpLink(linkSettings); link.AttachTo(session); var audience = this.BuildAudience(connectionString, path); await this.OpenLinkAsync(link, connectionString, audience, timeoutHelper.RemainingTime()); return link; }
public IotHubConnection(IotHubConnectionString connectionString, AccessRights accessRights) { this.connectionString = connectionString; this.accessRights = accessRights; this.faultTolerantSession = new FaultTolerantAmqpObject<AmqpSession>(this.CreateSessionAsync, this.CloseConnection); this.refreshTokenTimer = new IOThreadTimer(s => ((IotHubConnection)s).OnRefreshToken(), this, false); }
public IotHubSingleTokenConnection(IotHubScopeConnectionPool iotHubScopeConnectionPool, IotHubConnectionString connectionString, AmqpTransportSettings amqpTransportSettings) :base(connectionString.HostName, connectionString.AmqpEndpoint.Port, amqpTransportSettings) { this.iotHubScopeConnectionPool = iotHubScopeConnectionPool; this.ConnectionString = connectionString; this.FaultTolerantSession = new FaultTolerantAmqpObject<AmqpSession>(this.CreateSessionAsync, this.CloseConnection); }
public IotHubDeviceMuxConnection(IotHubDeviceScopeConnectionPool deviceScopeConnectionPool, long cacheKey, IotHubConnectionString connectionString, AmqpTransportSettings amqpTransportSettings) : base(connectionString.HostName, connectionString.AmqpEndpoint.Port, amqpTransportSettings) { this.deviceScopeConnectionPool = deviceScopeConnectionPool; this.cacheKey = cacheKey; this.FaultTolerantSession = new FaultTolerantAmqpObject<AmqpSession>(this.CreateSessionAsync, this.CloseConnection); this.iotHubTokenRefreshers = new ConcurrentDictionary<AmqpObject, IotHubTokenRefresher>(); }
public AmqpDeviceClient(IotHubConnectionString connectionString, bool useWebSocketOnly) { this.IotHubConnection = connectionCache.GetConnection(connectionString, useWebSocketOnly); this.deviceId = connectionString.DeviceId; this.openTimeout = IotHubConnection.DefaultOpenTimeout; this.operationTimeout = IotHubConnection.DefaultOperationTimeout; this.DefaultReceiveTimeout = IotHubConnection.DefaultOperationTimeout; this.faultTolerantEventSendingLink = new FaultTolerantAmqpObject<SendingAmqpLink>(this.CreateEventSendingLinkAsync, this.IotHubConnection.CloseLink); this.faultTolerantDeviceBoundReceivingLink = new FaultTolerantAmqpObject<ReceivingAmqpLink>(this.CreateDeviceBoundReceivingLinkAsync, this.IotHubConnection.CloseLink); }
internal HttpDeviceClient(IotHubConnectionString iotHubConnectionString) { this.deviceId = iotHubConnectionString.DeviceId; this.httpClientHelper = new HttpClientHelper( iotHubConnectionString.HttpsEndpoint, iotHubConnectionString, ExceptionHandlingHelper.GetDefaultErrorMapping(), DefaultOperationTimeout, null); this.DefaultReceiveTimeout = DefaultReceiveTimeoutInSeconds; }
public AmqpDeviceClient(IotHubConnectionString connectionString, AmqpTransportSettings transportSettings) { this.IotHubConnection = connectionCache.GetConnection(connectionString, transportSettings); this.deviceId = connectionString.DeviceId; this.openTimeout = IotHubConnection.DefaultOpenTimeout; this.operationTimeout = IotHubConnection.DefaultOperationTimeout; this.DefaultReceiveTimeout = IotHubConnection.DefaultOperationTimeout; this.faultTolerantEventSendingLink = new FaultTolerantAmqpObject<SendingAmqpLink>(this.CreateEventSendingLinkAsync, this.IotHubConnection.CloseLink); this.faultTolerantDeviceBoundReceivingLink = new FaultTolerantAmqpObject<ReceivingAmqpLink>(this.CreateDeviceBoundReceivingLinkAsync, this.IotHubConnection.CloseLink); this.prefetchCount = transportSettings.PrefetchCount; }
public IotHubTokenRefresher(AmqpSession amqpSession, IotHubConnectionString connectionString, string audience) { if (amqpSession == null) { throw new ArgumentNullException("amqpSession"); } this.amqpSession = amqpSession; this.connectionString = connectionString; this.audience = audience; }
DeviceClient(IotHubConnectionString iotHubConnectionString, ITransportSettings[] transportSettings) { this.iotHubConnectionString = iotHubConnectionString; #if !WINDOWS_UWP var innerHandler = new RetryDelegatingHandler( new ErrorDelegatingHandler( () => new RoutingDelegatingHandler(this.CreateTransportHandler, iotHubConnectionString, transportSettings))); #else // UWP does not support retry yet. We need to make the underlying Message stream accessible internally on UWP // to be sure that either the stream has not been read or it is seekable to safely retry operation var innerHandler = new ErrorDelegatingHandler( () => new RoutingDelegatingHandler(this.CreateTransportHandler, iotHubConnectionString, transportSettings)); #endif this.InnerHandler = new GateKeeperDelegatingHandler(innerHandler); }
protected override async Task OpenLinkAsync(AmqpObject link, IotHubConnectionString doNotUse, string doNotUse2, TimeSpan timeout) { try { await link.OpenAsync(timeout); } catch (Exception exception) { if (exception.IsFatal()) { throw; } link.SafeClose(exception); throw; } }
internal HttpDeviceClient(IotHubConnectionString iotHubConnectionString) { this.deviceId = iotHubConnectionString.DeviceId; this.httpClientHelper = new HttpClientHelper( iotHubConnectionString.HttpsEndpoint, iotHubConnectionString, DefaultOperationTimeout); this.DefaultReceiveTimeout = DefaultReceiveTimeoutInSeconds; // fill MapMessageProperties2HttpHeaders MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.Ack, CustomHeaderConstants.Ack); MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.CorrelationId, CustomHeaderConstants.CorrelationId); MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.ExpiryTimeUtc, CustomHeaderConstants.ExpiryTimeUtc); MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.MessageId, CustomHeaderConstants.MessageId); MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.Operation, CustomHeaderConstants.Operation); MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.To, CustomHeaderConstants.To); MapMessageProperties2HttpHeaders.Add(MessageSystemPropertyNames.UserId, CustomHeaderConstants.UserId); // make sure we are using RFC4648 encoding for Base64 (.Net MF default is not RFC4648) Convert.UseRFC4648Encoding = true; }
public IotHubDeviceMuxConnection(IotHubDeviceScopeConnectionPool deviceScopeConnectionPool, long cacheKey, IotHubConnectionString connectionString, AmqpTransportSettings amqpTransportSettings) : base(connectionString.HostName, connectionString.AmqpEndpoint.Port, amqpTransportSettings) { this.deviceScopeConnectionPool = deviceScopeConnectionPool; this.cacheKey = cacheKey; this.FaultTolerantSession = new FaultTolerantAmqpObject <AmqpSession>(this.CreateSessionAsync, this.CloseConnection); this.iotHubTokenRefreshers = new ConcurrentDictionary <AmqpObject, IotHubTokenRefresher>(); }
protected override string BuildAudience(IotHubConnectionString doNotUse, string donotUse2) { return string.Empty; }
internal static InternalClient CreateFromConnectionString( string connectionString, IAuthenticationMethod authenticationMethod, ITransportSettings[] transportSettings, IDeviceClientPipelineBuilder pipelineBuilder, ClientOptions options = default) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (transportSettings == null) { throw new ArgumentNullException(nameof(transportSettings)); } if (transportSettings.Length == 0) { throw new ArgumentOutOfRangeException(nameof(connectionString), "Must specify at least one TransportSettings instance"); } if (!string.IsNullOrWhiteSpace(options?.ModelId) && transportSettings.Any(x => x.GetTransportType() == TransportType.Http1)) { throw new InvalidOperationException("Plug and Play is not supported over the HTTP transport."); } var builder = IotHubConnectionStringBuilder.CreateWithIAuthenticationOverride( connectionString, authenticationMethod); // Clients that derive their authentication method from AuthenticationWithTokenRefresh will need to specify // the token time to live and renewal buffer values through the corresponding AuthenticationWithTokenRefresh // implementation constructors instead. if (!(builder.AuthenticationMethod is AuthenticationWithTokenRefresh)) { builder.SasTokenTimeToLive = options?.SasTokenTimeToLive ?? default; builder.SasTokenRenewalBuffer = options?.SasTokenRenewalBuffer ?? default; } IotHubConnectionString iotHubConnectionString = builder.ToIotHubConnectionString(); foreach (ITransportSettings transportSetting in transportSettings) { switch (transportSetting.GetTransportType()) { case TransportType.Amqp_WebSocket_Only: case TransportType.Amqp_Tcp_Only: if (!(transportSetting is AmqpTransportSettings)) { throw new InvalidOperationException("Unknown implementation of ITransportSettings type"); } break; case TransportType.Http1: if (!(transportSetting is Http1TransportSettings)) { throw new InvalidOperationException("Unknown implementation of ITransportSettings type"); } break; case TransportType.Mqtt_WebSocket_Only: case TransportType.Mqtt_Tcp_Only: if (!(transportSetting is MqttTransportSettings)) { throw new InvalidOperationException("Unknown implementation of ITransportSettings type"); } break; default: throw new InvalidOperationException("Unsupported Transport Type {0}".FormatInvariant(transportSetting.GetTransportType())); } } if (authenticationMethod is DeviceAuthenticationWithX509Certificate && builder.Certificate == null) { throw new ArgumentException("No certificate was found. To use certificate authentication certificate must be present."); } // Make sure client options is initialized with the correct transport setting. EnsureOptionsIsSetup(builder.Certificate, ref options); pipelineBuilder ??= BuildPipeline(); // Defer concrete InternalClient creation to OpenAsync var client = new InternalClient(iotHubConnectionString, transportSettings, pipelineBuilder, options); if (Logging.IsEnabled) { Logging.CreateFromConnectionString( client, $"HostName={iotHubConnectionString.HostName};DeviceId={iotHubConnectionString.DeviceId};ModuleId={iotHubConnectionString.ModuleId}", transportSettings, options); } return(client); }
protected abstract Task OpenLinkAsync(AmqpObject link, IotHubConnectionString connectionString, string audience, TimeSpan timeout, CancellationToken cancellationToken);
protected abstract Uri BuildLinkAddress(IotHubConnectionString iotHubConnectionString, string path);
DeviceClient(IotHubConnectionString iotHubConnectionString) { this.InnerHandler = new GateKeeperDelegatingHandler( new ErrorDelegatingHandler(() => new HttpTransportHandler(iotHubConnectionString))); }
internal static InternalClient CreateFromConnectionString( string connectionString, IAuthenticationMethod authenticationMethod, ITransportSettings[] transportSettings, IDeviceClientPipelineBuilder pipelineBuilder, ClientOptions options = default) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (transportSettings == null) { throw new ArgumentNullException(nameof(transportSettings)); } if (transportSettings.Length == 0) { throw new ArgumentOutOfRangeException(nameof(connectionString), "Must specify at least one TransportSettings instance"); } var builder = IotHubConnectionStringBuilder.CreateWithIAuthenticationOverride( connectionString, authenticationMethod); IotHubConnectionString iotHubConnectionString = builder.ToIotHubConnectionString(); foreach (ITransportSettings transportSetting in transportSettings) { switch (transportSetting.GetTransportType()) { case TransportType.Amqp_WebSocket_Only: case TransportType.Amqp_Tcp_Only: if (!(transportSetting is AmqpTransportSettings)) { throw new InvalidOperationException("Unknown implementation of ITransportSettings type"); } break; case TransportType.Http1: if (!(transportSetting is Http1TransportSettings)) { throw new InvalidOperationException("Unknown implementation of ITransportSettings type"); } break; case TransportType.Mqtt_WebSocket_Only: case TransportType.Mqtt_Tcp_Only: if (!(transportSetting is MqttTransportSettings)) { throw new InvalidOperationException("Unknown implementation of ITransportSettings type"); } break; default: throw new InvalidOperationException("Unsupported Transport Type {0}".FormatInvariant(transportSetting.GetTransportType())); } } pipelineBuilder = pipelineBuilder ?? BuildPipeline(); // Defer concrete InternalClient creation to OpenAsync var client = new InternalClient(iotHubConnectionString, transportSettings, pipelineBuilder, options); if (Logging.IsEnabled) { Logging.CreateFromConnectionString(client, $"HostName={iotHubConnectionString.HostName};DeviceId={iotHubConnectionString.DeviceId};ModuleId={iotHubConnectionString.ModuleId}", transportSettings, options); } return(client); }
protected override string BuildAudience(IotHubConnectionString doNotUse, string donotUse2) { return(string.Empty); }
protected override Uri BuildLinkAddress(IotHubConnectionString doNotUse, string path) { return(this.ConnectionString.BuildLinkAddress(path)); }
public IotHubSingleTokenConnection(IotHubScopeConnectionPool iotHubScopeConnectionPool, IotHubConnectionString connectionString, AmqpTransportSettings amqpTransportSettings) : base(connectionString.HostName, connectionString.AmqpEndpoint.Port, amqpTransportSettings) { this.iotHubScopeConnectionPool = iotHubScopeConnectionPool; this.ConnectionString = connectionString; this.FaultTolerantSession = new FaultTolerantAmqpObject <AmqpSession>(this.CreateSessionAsync, this.CloseConnection); }
public async Task <SendingAmqpLink> CreateSendingLinkAsync( string path, IotHubConnectionString connectionString, string corrId, SendingLinkType linkType, TimeSpan timeout, ProductInfo productInfo, CancellationToken cancellationToken) { this.OnCreateSendingLink(connectionString); var timeoutHelper = new TimeoutHelper(timeout); AmqpSession session = await this.GetSessionAsync(timeoutHelper, cancellationToken).ConfigureAwait(false); var linkAddress = this.BuildLinkAddress(connectionString, path); var linkSettings = new AmqpLinkSettings() { Role = false, InitialDeliveryCount = 0, Target = new Target() { Address = linkAddress.AbsoluteUri }, LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debugging }; switch (linkType) { case SendingLinkType.TelemetryEvents: linkSettings.SndSettleMode = null; // SenderSettleMode.Unsettled (null as it is the default and to avoid bytes on the wire) linkSettings.RcvSettleMode = null; // (byte)ReceiverSettleMode.First (null as it is the default and to avoid bytes on the wire) break; case SendingLinkType.Methods: case SendingLinkType.Twin: linkSettings.SndSettleMode = (byte)SenderSettleMode.Settled; linkSettings.RcvSettleMode = (byte)ReceiverSettleMode.First; break; } SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime(), productInfo); if (linkType == SendingLinkType.Methods) { SetLinkSettingsCommonPropertiesForMethod(linkSettings, corrId); } else if (linkType == SendingLinkType.Twin) { SetLinkSettingsCommonPropertiesForTwin(linkSettings, corrId); } var link = new SendingAmqpLink(linkSettings); link.AttachTo(session); var audience = this.BuildAudience(connectionString, path); await this.OpenLinkAsync(link, connectionString, audience, timeoutHelper.RemainingTime(), cancellationToken).ConfigureAwait(false); return(link); }
protected override string BuildAudience(IotHubConnectionString iotHubConnectionString, string path) { return(iotHubConnectionString.Audience + path); }
protected override Uri BuildLinkAddress(IotHubConnectionString iotHubConnectionString, string path) { return(iotHubConnectionString.BuildLinkAddress(path)); }
public bool RemoveDeviceScopeConnectionPool(IotHubConnectionString connectionString) { IotHubDeviceScopeConnectionPool iotHubDeviceScopeConnectionPool; return(this.deviceScopeConnectionPools.TryRemove(connectionString, out iotHubDeviceScopeConnectionPool)); }
protected override async Task OpenLinkAsync(AmqpObject link, IotHubConnectionString connectionString, string audience, TimeSpan timeout) { var timeoutHelper = new TimeoutHelper(timeout); try { // this is a device-scope connection string. We need to send a CBS token for this specific link before opening it. var iotHubLinkTokenRefresher = new IotHubTokenRefresher( this.FaultTolerantSession.Value, connectionString, audience ); if (this.iotHubTokenRefreshers.TryAdd(link, iotHubLinkTokenRefresher)) { link.SafeAddClosed((s, e) => { if (this.iotHubTokenRefreshers.TryRemove(link, out iotHubLinkTokenRefresher)) { iotHubLinkTokenRefresher.Cancel(); } }); // Send Cbs token for new link first await iotHubLinkTokenRefresher.SendCbsTokenAsync(timeoutHelper.RemainingTime()); } // Open Amqp Link await link.OpenAsync(timeoutHelper.RemainingTime()); } catch (Exception exception) { if (exception.IsFatal()) { throw; } link.SafeClose(exception); throw; } }
protected override string BuildAudience(IotHubConnectionString iotHubConnectionString, string path) { return iotHubConnectionString.Audience + path; }
protected virtual void OnCreateReceivingLink(IotHubConnectionString connectionString) { // do nothing. Override in derived classes if necessary }
protected override Uri BuildLinkAddress(IotHubConnectionString iotHubConnectionString, string path) { return iotHubConnectionString.BuildLinkAddress(path); }
public async Task <ReceivingAmqpLink> CreateReceivingLinkAsync( string path, IotHubConnectionString connectionString, string corrId, ReceivingLinkType linkType, uint prefetchCount, TimeSpan timeout, CancellationToken cancellationToken) { this.OnCreateReceivingLink(connectionString); var timeoutHelper = new TimeoutHelper(timeout); AmqpSession session = await this.GetSessionAsync(timeoutHelper, cancellationToken); var linkAddress = this.BuildLinkAddress(connectionString, path); var linkSettings = new AmqpLinkSettings() { Role = true, TotalLinkCredit = prefetchCount, AutoSendFlow = prefetchCount > 0, Source = new Source() { Address = linkAddress.AbsoluteUri }, LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debuggin }; switch (linkType) { case ReceivingLinkType.C2DMessages: linkSettings.SndSettleMode = null; // SenderSettleMode.Unsettled (null as it is the default and to avoid bytes on the wire) linkSettings.RcvSettleMode = (byte)ReceiverSettleMode.Second; break; case ReceivingLinkType.Methods: case ReceivingLinkType.Twin: linkSettings.SndSettleMode = (byte)SenderSettleMode.Settled; linkSettings.RcvSettleMode = (byte)ReceiverSettleMode.First; break; } SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime()); if (linkType == ReceivingLinkType.Methods) { SetLinkSettingsCommonPropertiesForMethod(linkSettings, corrId); } else if (linkType == ReceivingLinkType.Twin) { SetLinkSettingsCommonPropertiesForTwin(linkSettings, corrId); } var link = new ReceivingAmqpLink(linkSettings); link.AttachTo(session); var audience = this.BuildAudience(connectionString, path); await this.OpenLinkAsync(link, connectionString, audience, timeoutHelper.RemainingTime(), cancellationToken); return(link); }
public DeviceAuthenticationWithSakRefresh( string deviceId, IotHubConnectionString connectionString) : base(deviceId) { _connectionString = connectionString; }
protected abstract string BuildAudience(IotHubConnectionString iotHubConnectionString, string path);
protected abstract Task OpenLinkAsync(AmqpObject link, IotHubConnectionString connectionString, string audience, TimeSpan timeout);
// Making this virtual to allow Moq to override public virtual bool RemoveHubScopeConnectionPool(IotHubConnectionString connectionString) { IotHubScopeConnectionPool iotHubScopeConnectionPool; return(this.hubScopeConnectionPools.TryRemove(connectionString, out iotHubScopeConnectionPool)); }
protected override Uri BuildLinkAddress(IotHubConnectionString doNotUse, string path) { return this.ConnectionString.BuildLinkAddress(path); }
DeviceClient(IotHubConnectionString iotHubConnectionString, ITransportSettings[] transportSettings) { this.iotHubConnectionString = iotHubConnectionString; this.transportSettings = transportSettings; }
public DeviceAuthenticationWithSakRefresh( string deviceId, IotHubConnectionString connectionString) : base(deviceId) { _connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString)); }
public async Task <SendingAmqpLink> CreateMethodSendingLinkAsync(string path, IotHubConnectionString connectionString, TimeSpan timeout, CancellationToken cancellationToken, string deviceId) { this.OnCreateSendingLink(connectionString); var timeoutHelper = new TimeoutHelper(timeout); AmqpSession session; if (!this.FaultTolerantSession.TryGetOpenedObject(out session)) { session = await this.FaultTolerantSession.GetOrCreateAsync(timeoutHelper.RemainingTime(), cancellationToken); } var linkAddress = this.BuildLinkAddress(connectionString, path); var linkSettings = new AmqpLinkSettings() { Role = false, InitialDeliveryCount = 0, Target = new Target() { Address = linkAddress.AbsoluteUri }, SndSettleMode = (byte)SenderSettleMode.Settled, RcvSettleMode = (byte)ReceiverSettleMode.First, LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debugging }; SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime()); SetLinkSettingsCommonPropertiesForMethod(linkSettings, deviceId); var link = new SendingAmqpLink(linkSettings); link.AttachTo(session); var audience = this.BuildAudience(connectionString, path); await this.OpenLinkAsync(link, connectionString, audience, timeoutHelper.RemainingTime(), cancellationToken); return(link); }
DefaultDelegatingHandler CreateTransportHandler(IotHubConnectionString iotHubConnectionString, ITransportSettings transportSetting) { switch (transportSetting.GetTransportType()) { case TransportType.Amqp_WebSocket_Only: case TransportType.Amqp_Tcp_Only: return new AmqpTransportHandler(iotHubConnectionString, transportSetting as AmqpTransportSettings); case TransportType.Http1: return new HttpTransportHandler(iotHubConnectionString, transportSetting as Http1TransportSettings); #if !WINDOWS_UWP && !NETMF case TransportType.Mqtt: return new MqttTransportHandler(iotHubConnectionString, transportSetting as MqttTransportSettings); #endif default: throw new InvalidOperationException("Unsupported Transport Setting {0}".FormatInvariant(transportSetting)); } }
internal HttpDeviceClient(IotHubConnectionString iotHubConnectionString, Http1TransportSettings transportSettings) :this(iotHubConnectionString) { this.transportSettings = transportSettings; }