I am looking at MQTT as a replacement for a ‘hack’ I currently use for a turn based game. I noticed that I can’t check in a easy way if the MQTT client is connected successfully to the server. tried looking at the JS code for the extension but it seems it’s minified, so I can’t actually modify/edit it. Any ideas what I could look to be able to check for the connected status or should I just trust the client to always connect to the server?
I think I managed to do it. I added a couple of listeners under the connect function in the MQTT extension:
// Set the connection flag
gdjs.evtTools.mqtt.connection.on("open", function(e) {
gdjs.evtTools.mqtt.connected = "1";
});
// Reset the connection flag
gdjs.evtTools.mqtt.connection.on("close", function(e) {
gdjs.evtTools.mqtt.connected = "0";
});
I also created a new condition function “IsConnected”
// Return the connected flag
eventsFunctionContext.returnValue = gdjs.evtTools.mqtt.connected;