Add onDesktopDisconnect hook, refactor plugin hooks on front end to be variable
Ryan Blenis committed
Nov 13, 2019 at 16:31 UTC
786934b72c704a83901320ab08c290edb71529a3
2 files changed
+8
-5
pluginHandler.js
+6
-4
@@ -66,13 +66,15 @@ module.exports.pluginHandler = function (parent) {
66
}
67
}
68
69
- str += `obj.onDeviceRefeshEnd = function(nodeid, panel, refresh, event) {
70
- for (const p of Object.keys(obj)) {
71
- if (typeof obj[p].onDeviceRefreshEnd == 'function') {
72
- obj[p].onDeviceRefreshEnd(nodeid, panel, refresh, event);
69
+ str += `
70
+ obj.callHook = function(hookName, ...args) {
71
+ for (const p of Object.keys(obj)) {
72
+ if (typeof obj[p][hookName] == 'function') {
73
+ obj[p][hookName](args);
74
}
75
}
76
};
77
+
78
obj.registerPluginTab = function(pluginRegInfo) {
79
var d = pluginRegInfo();
80
if (!Q(d.tabId)) {
views/default.handlebars
+2
-1
@@ -4540,7 +4540,7 @@
4540
p13clearConsoleMsg();
4541
4542
// Device refresh plugin handler
4543
- if (pluginHandler != null) { pluginHandler.onDeviceRefeshEnd(nodeid, panel, refresh, event); }
4543
+ if (pluginHandler != null) { pluginHandler.callHook('onDeviceRefreshEnd', nodeid, panel, refresh, event); }
4544
}
4545
setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
4546
if (!panel) panel = 10;
@@ -5201,6 +5201,7 @@
5201
desktop.Stop();
5202
webRtcDesktopReset();
5203
desktopNode = desktop = null;
5204
+ if (pluginHandler != null) { pluginHandler.callHook('onDesktopDisconnect'); }
5205
}
5206
}
5207