-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_helper.js
37 lines (32 loc) · 972 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
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
var NodeHelper = require("node_helper");
var log = (...args) => { /* do nothing */ };
var LibCast = require("./components/castLib.js");
module.exports = NodeHelper.create({
socketNotificationReceived (noti, payload) {
switch (noti) {
case "INIT":
console.log("[CAST] EXT-YouTubeCast Version:", require("./package.json").version, "rev:", require("./package.json").rev);
this.initialize(payload);
break;
}
},
async initialize (config) {
this.config = config;
if (this.config.debug) log = (...args) => { console.log("[CAST]", ...args); };
this.serverStart();
},
serverStart () {
log("Starting...");
if (this.config.castName) {
this.cast = new LibCast(
this.config,
(noti, params) => this.sendSocketNotification(noti, params),
this.config.debug
);
this.cast.start();
} else {
this.sendSocketNotification("CAST_WARNING");
}
}
});