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:
parent
4094daf58f
commit
8f0517b80c
5 changed files with 134 additions and 0 deletions
10
webserver.js
10
webserver.js
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue