File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed
Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -617,21 +617,24 @@ function connect() {
617617 jQuery(" .offlineMarker" ).hide ();
618618 jQuery(" .loadingMarker" ).show ();
619619
620- client = new Paho.MQTT.Client (" $Extras.mqtt_websockets_host" , $Extras .mqtt_websockets_port , mqttclient);
621- client.onConnectionLost = onConnectionLost;
622- client.onMessageArrived = onMessageArrived;
623- var options = {
624- #if $Extras .has_key (" mqtt_websockets_ssl" ) and $Extras .mqtt_websockets_ssl == '1'
625- useSSL: true,
626- #else
627- useSSL: false,
628- #end if
629- onSuccess:onConnect,
630- onFailure:onFailure
631- }
620+ if (location.protocol === 'https:')
621+ {
622+ client = new Paho.MQTT.Client (" $Extras.mqtt_websockets_host" , $Extras .mqtt_websockets_port_ssl , mqttclient);
623+ client.onConnectionLost = onConnectionLost;
624+ client.onMessageArrived = onMessageArrived;
625+ var options = {useSSL: true,onSuccess:onConnect,onFailure:onFailure}
626+ }
627+ else
628+ {
629+ client = new Paho.MQTT.Client (" $Extras.mqtt_websockets_host" , $Extras .mqtt_websockets_port , mqttclient);
630+ client.onConnectionLost = onConnectionLost;
631+ client.onMessageArrived = onMessageArrived;
632+ var options = {useSSL: false,onSuccess:onConnect,onFailure:onFailure}
633+ }
632634 client.connect ( options );
633635}
634636
637+
635638// MQTT connect callback
636639function onConnect() {
637640 belchertown_debug(" MQTT Connected. Subscribing." );
You can’t perform that action at this time.
0 commit comments