-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
51 lines (41 loc) · 1.3 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module.exports = async (SmartNodeServerPlugin) => {
let socket = SmartNodeServerPlugin.socket;
let lines = ['',''];
return {
load,
unload,
unpair
}
function unpair() {}
function load() {
SmartNodeServerPlugin.addDisplayData('displayline1', {
description: "Line 1",
type: "string",
value: lines[0]
});
SmartNodeServerPlugin.addDisplayData('displayline2', {
description: "Line 2",
type: "string",
value: lines[1]
});
_initRender(SmartNodeServerPlugin.getGlobals());
SmartNodeServerPlugin.on('globalsChanged', (changed) => {
_initRender(SmartNodeServerPlugin.getGlobals());
});
}
function unload() {
SmartNodeServerPlugin.removeAllListeners('globalsChanged');
}
function _initRender(data) {
socket.emit('render', data, (renderedLines) => {
lines = renderedLines;
global.muted('Display rendered', lines);
SmartNodeServerPlugin.updateDisplayData('displayline1', {
value: lines[0]
});
SmartNodeServerPlugin.updateDisplayData('displayline2', {
value: lines[1]
});
});
}
}