1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added MQTT support over WSS and multiplexed with MPS

This commit is contained in:
jsastriawan 2019-10-02 17:57:18 -07:00
parent 4094daf58f
commit 8f0517b80c
5 changed files with 134 additions and 0 deletions

View file

@ -3323,6 +3323,16 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
try { obj.meshAgentHandler.CreateMeshAgent(obj, obj.db, ws, req, obj.args, domain); } catch (e) { console.log(e); }
});
// MQTT broker over websocket
obj.app.ws(url+'mqtt.ashx', function (ws, req) {
var ser = SerialTunnel();
ws.on('message', function(b) { ser.updateBuffer(Buffer.from(b,'binary'))});
ser.forwardwrite = function(b) { ws.send(b,"binary")}
ws.on("close", function() { ser.emit('end');});
//pass socket wrapper to mqtt broker
obj.parent.mqttbroker.handle(ser);
})
// Memory Tracking
if (typeof obj.args.memorytracking == 'number') {
obj.app.get(url + 'memorytracking.csv', function (req, res) {