-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (47 loc) · 1.08 KB
/
index.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
const { InstanceBase, InstanceStatus, runEntrypoint } = require('@companion-module/base')
const UpgradeScripts = require('./src/upgrades');
const actions = require('./src/actions.js')
const initAPI = require('./src/api.js')
const configFields = require('./src/config.js')
/**
* Companion instance class for draco tera
*/
class dracotera extends InstanceBase {
// Identation for some console outputs.
console_ident = 5;
constructor(internal) {
super(internal)
Object.assign(this, {
...configFields,
...actions,
...initAPI,
}
)
this.KEEPALIVE = null;
}
// Init module
async init(config) {
this.updateStatus(InstanceStatus.Connecting);
this.configUpdated(config);
}
// Configuration changed
async configUpdated(config) {
if (config) {
this.config = config;
}
this.initActions();
this.initAPI();
}
// Instance removal clean up
destroy() {
if(this.KEEPALIVE) {
clearInterval(this.KEEPALIVE)
delete this.KEEPALIVE;
}
if (this.socket) {
this.socket.destroy();
delete this.socket;
}
}
}
runEntrypoint(dracotera, UpgradeScripts);