Merge pull request #610 from ryanblenis/plugin

Expand PluginHandler to Support Periodic Updates
This commit is contained in:
Ylian Saint-Hilaire 2019-10-28 09:12:29 -07:00 committed by GitHub
commit 630c760d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -2573,7 +2573,7 @@ function createMeshCore(agent) {
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
}
// TODO: add plugin hook here
mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"});
}

View File

@ -2517,7 +2517,7 @@ function createMeshCore(agent) {
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
}
// TODO: add plugin hook here
mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"});
}

View File

@ -1278,7 +1278,11 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if (typeof command.plugin != 'string') break;
try {
var pluginHandler = require('./pluginHandler.js').pluginHandler(parent.parent);
if (command.plugin == '__all') {
pluginHandler.callHook(command.hook, command, obj, parent);
} else {
pluginHandler.plugins[command.plugin].serveraction(command, obj, parent);
}
} catch (e) {
console.log('Error loading plugin handler (' + e + ')');
}