forked from PabloDons/MMM-Skyss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_helper.js
More file actions
31 lines (30 loc) · 995 Bytes
/
node_helper.js
File metadata and controls
31 lines (30 loc) · 995 Bytes
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
const NodeHelper = require("node_helper");
const https = require("https");
module.exports = NodeHelper.create({
start: function(){
console.log("Starting module: " + this.name)
},
socketNotificationReceived: function (notification, payload) {
var self = this;
if (notification == "getstop") {
const options = {
hostname: 'skyss.giantleap.no',
path: payload
};
var req = https.get(options, (res)=>{
res.setEncoding('utf8');
var data = "";
res.on('data', (chunk) => {
data = data.concat(chunk);
});
res.on('end', ()=>{
self.sendSocketNotification("getstop", {response:data});
});
});
req.on('error', (e) => {
self.sendSocketNotification("getstop", {err:e});
});
req.end();
}
}
});