-
Notifications
You must be signed in to change notification settings - Fork 3
/
node_helper.js
60 lines (54 loc) · 1.47 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Magic Mirror
* Node Helper: Newsfeed
*
* By Michael Teeuw http://michaelteeuw.nl
* MIT Licensed.
*/
var NodeHelper = require("node_helper")
var fs = require("fs");
var Freeboxapi = require("./freeboxapi.js");
var fapi;
module.exports = NodeHelper.create({
// Subclass start method.
start: function() {
var self = this;
self.fapi = new Freeboxapi("..");
self.fapi.onError(function(fapi, error) {
self.sendSocketNotification("FREEBOX_ERROR", {
error: error
});
});
self.fapi.onMsg(function(fapi, msg) {
self.sendSocketNotification("FREEBOX_MSG", {
value: msg.value,
type: msg.type
});
});
console.log("Starting module: " + this.name);
},
// Subclass socketNotificationReceived received.
socketNotificationReceived: function(notification, payload) {
var self = this;
console.log("FREEBOX: "+JSON.stringify(notification)+ " " +payload);
if (notification === "GET_CALLS") {
self.fapi.getCalls();
return;
}else if (notification === "GET_DOWNLOADS") {
self.fapi.getDownloads();
return;
}else if (notification === "GET_CONNECTED_DEVICES") {
self.fapi.getConnectedDevices();
return;
}else if (notification === "GET_CONNECTIONSTATUS") {
self.fapi.getConnectionStatus();
return;
}else if (notification === "GET_SYSTEMINFO") {
self.fapi.getSystemInfo();
return;
}else if (notification === "CONNECT"){
self.fapi.configure(payload.config);
self.fapi.readFreeboxVersion();
return;
}
}
});