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

Merge pull request #530 from jsastriawan/add_mqtt

Added MQTT support over WSS and multiplexed with MPS
This commit is contained in:
Ylian Saint-Hilaire 2019-10-04 11:37:18 -07:00 committed by GitHub
commit baff9c690a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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) {