From daed74403ae5d8dbf72756cd8696b5057498f34c Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Sun, 27 Oct 2019 19:43:39 -0400 Subject: [PATCH] Enable mesh agents to engage with plugins via the sendPeriodicServerUpdate call --- agents/meshcore.js | 2 +- agents/meshcore.min.js | 2 +- meshagent.js | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 7800b72f..adee50d2 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -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"}); } diff --git a/agents/meshcore.min.js b/agents/meshcore.min.js index c64e8a59..e8788bd2 100644 --- a/agents/meshcore.min.js +++ b/agents/meshcore.min.js @@ -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"}); } diff --git a/meshagent.js b/meshagent.js index bf840f59..50e75982 100644 --- a/meshagent.js +++ b/meshagent.js @@ -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); - pluginHandler.plugins[command.plugin].serveraction(command, obj, 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 + ')'); }