-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.js
More file actions
68 lines (56 loc) · 1.52 KB
/
Copy pathmain.js
File metadata and controls
68 lines (56 loc) · 1.52 KB
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
61
62
63
64
65
66
67
68
const { InstanceBase, Regex, InstanceStatus } = require('@companion-module/base')
const CreateClient = require('./src/connect')
const InitActions = require('./src/actions')
const InitPresets = require('./src/presets')
const { InitVariables, StopUpdatingVariables } = require('./src/variables')
const InitFeedback = require('./src/feedback')
const configuration = [
{
type: 'textinput',
id: 'host',
label: 'Destination IP',
width: 8,
default: '127.0.0.1',
regex: Regex.IP,
},
{
type: 'textinput',
id: 'port',
label: 'Port',
width: 4,
default: 5505,
regex: Regex.PORT,
},
]
class ModuleInstance extends InstanceBase {
constructor(internal) {
super(internal)
}
async init(config) {
this.config = config
this.updateStatus(InstanceStatus.Warning, 'Could not connect to WebSocket server')
this.initializedVariables = []
this.internalVariable = {}
this.requestActionValues = () => this.socket?.emit('data', JSON.stringify({ action: 'get_actions' }))
this.initWebSocket()
this.initActions()
this.initFeedback()
this.initPresets()
this.initVariables()
}
async destroy() {
this.log('debug', 'Module deleted!')
StopUpdatingVariables()
}
async configUpdated(config) {
this.config = config
this.initWebSocket()
}
getConfigFields = () => configuration
initWebSocket = () => CreateClient(this)
initActions = () => InitActions(this)
initPresets = () => InitPresets(this)
initVariables = () => InitVariables(this)
initFeedback = () => InitFeedback(this)
}
module.exports = ModuleInstance