Skip to content

Commit a0134a0

Browse files
authored
Merge pull request #246 from ryan-kramer/patch-1
Update belchertown.js.tmpl
2 parents c9203ed + d4ea390 commit a0134a0

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

skins/Belchertown/js/belchertown.js.tmpl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff 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
636639
function onConnect() {
637640
belchertown_debug("MQTT Connected. Subscribing.");

0 commit comments

Comments
 (0)