-
Notifications
You must be signed in to change notification settings - Fork 6
/
node_helper.js
36 lines (28 loc) · 1.02 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
var NodeHelper = require("node_helper");
// add require of other javascripot components here
// var xxx = require('yyy') here
module.exports = NodeHelper.create({
init(){
console.log("init module helper SampleModule");
},
start() {
console.log('Starting module helper:' +this.name);
},
stop(){
console.log('Stopping module helper: ' +this.name);
},
// handle messages from our module// each notification indicates a different messages
// payload is a data structure that is different per message.. up to you to design this
socketNotificationReceived(notification, payload) {
console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
// if config message from module
if (notification === "CONFIG") {
// save payload config info
this.config=payload
// wait 15 seconds, send a message back to module
setTimeout(()=> { this.sendSocketNotification("message_from_helper"," this is a test_message")}, 15000)
}
else if(notification === "????2") {
}
},
});