-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_helper.js
25 lines (20 loc) · 963 Bytes
/
node_helper.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
const bodyParser = require("body-parser")
var NodeHelper = require("node_helper")
module.exports = NodeHelper.create({
socketNotificationReceived: function(notification, payload) {
if (notification == "INIT") {
this.expressApp.use(bodyParser.json());
this.expressApp.use(bodyParser.urlencoded({ extended: true }));
// frames with html defined will retrieve data from the mothership
for (var i = 0; i < payload.frames.length; i++) {
if (payload.frames[i].html !== undefined) {
var index = i // conserve value in local variable, needed for enclosure to work
this.expressApp.get("/HOYMILES-" + payload.ident + "-" + index, (req, res) => {
res.status(200).send(payload.frames[index].html); });
}
}
// initialization done
this.sendSocketNotification('INIT_DONE', { });
}
},
})