private void openConnection()

in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/IotHubTransport.java [1367:1417]


    private void openConnection() throws TransportException
    {
        if (this.iotHubTransportConnection == null)
        {
            switch (this.protocol)
            {
                case HTTPS:
                    this.iotHubTransportConnection = new HttpsIotHubConnection(this.getDefaultConfig());
                    break;
                case MQTT:
                case MQTT_WS:
                    this.iotHubTransportConnection = new MqttIotHubConnection(this.getDefaultConfig());
                    break;
                case AMQPS:
                case AMQPS_WS:
                    if (this.isMultiplexing)
                    {
                        // The default config is only null when someone creates a multiplexing client and opens it before
                        // registering any devices to it
                        this.iotHubTransportConnection = new AmqpsIotHubConnection(
                                this.hostName,
                                this.transportUniqueIdentifier,
                                this.protocol == IotHubClientProtocol.AMQPS_WS,
                                this.sslContext,
                                this.proxySettings,
                                this.keepAliveInterval,
                                this.sendInterval,
                                this.useIdentifiableThreadNames,
                                this.threadNamePrefix,
                                this.threadNameSuffix);

                        for (ClientConfiguration config : this.deviceClientConfigs.values())
                        {
                            ((AmqpsIotHubConnection) this.iotHubTransportConnection).registerMultiplexedDevice(config);
                        }
                    }
                    else
                    {
                        this.iotHubTransportConnection = new AmqpsIotHubConnection(this.getDefaultConfig(), this.transportUniqueIdentifier);
                    }

                    break;
                default:
                    throw new TransportException("Protocol not supported");
            }
        }

        this.iotHubTransportConnection.setListener(this);
        this.iotHubTransportConnection.open();
        this.updateStatus(IotHubConnectionStatus.CONNECTED, IotHubConnectionStatusChangeReason.CONNECTION_OK, null);
    }