Enable mesh agents to engage with plugins via the sendPeriodicServerUpdate call
Ryan Blenis committed
Oct 27, 2019 at 19:43 UTC
37abddb7a4a1bf462d51aafedae43b72384f4c2d
3 files changed
+7
-3
agents/meshcore.js
+1
-1
@@ -2573,7 +2573,7 @@ function createMeshCore(agent) {
2573
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
2574
}
2575
2576
- // TODO: add plugin hook here
2576
+ mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"});
2577
}
2578
2579
agents/meshcore.min.js
+1
-1
@@ -2517,7 +2517,7 @@ function createMeshCore(agent) {
2517
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
2518
}
2519
2520
- // TODO: add plugin hook here
2520
+ mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"});
2521
}
2522
2523
meshagent.js
+5
-1
@@ -1278,7 +1278,11 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1278
if (typeof command.plugin != 'string') break;
1279
try {
1280
var pluginHandler = require('./pluginHandler.js').pluginHandler(parent.parent);
1281
- pluginHandler.plugins[command.plugin].serveraction(command, obj, parent);
1281
+ if (command.plugin == '__all') {
1282
+ pluginHandler.callHook(command.hook, command, obj, parent);
1283
+ } else {
1284
+ pluginHandler.plugins[command.plugin].serveraction(command, obj, parent);
1285
+ }
1286
} catch (e) {
1287
console.log('Error loading plugin handler (' + e + ')');
1288
}