Working with WebSockets to connect to the MQTT server
The following lines declare the onConnectSuccess
and connect
functions within the APP.HomeAutomation.Manager
object. The code file for the sample is included in the mqtt_essentials_gaston_hillar_05
folder, in the home_automation.js
file:
onConnectSuccess: function(invocationContext) { onConnectSuccess: function(invocationContext) { // Update the status text document.getElementById("status").textContent = "Connected with the MQTT Server"; // Now, subscribe to home/results/leds/1, home/results/leds/2 and // home/results/leds/3 var client = invocationContext.invocationContext.client; for (var i = 1; i < 4; i++) { client.subscribe("home/results/leds/" + i); } }, connect: function() { this.client = new Paho.MQTT.Client(this.host, this.port, this.clientId); this.client.onConnectionLost = this.onConnectionLost; this.client.onMessageArrived...