-
Notifications
You must be signed in to change notification settings - Fork 1
/
actions.js
37 lines (31 loc) · 883 Bytes
/
actions.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
export function getActionDefinitions(self) {
const actions = {}
const createSimpleCommandAction = (name, command) => ({
name: `${name}`,
options: [],
callback: async () => {
const cmd = command
const sendBuf = Buffer.from(cmd, 'latin1')
self.socket.send(sendBuf)
},
})
const simpleCommands = {
ESC: 'esc',
NEXT: 'next',
PREVIOUS: 'previous',
EXIT_PPT: 'pptexit',
EXIT_VIDEO: 'videoexit',
}
for (let i = 1; i <= 20; i++) {
const pptCommand = `PPT${i.toString().padStart(2, '0')}`
simpleCommands[pptCommand] = pptCommand.toLowerCase()
}
for (let i = 1; i <= 10; i++) {
const videoCommand = `VIDEO${i.toString().padStart(2, '0')}`
simpleCommands[videoCommand] = videoCommand.toLowerCase()
}
for (const [name, command] of Object.entries(simpleCommands)) {
actions[name] = createSimpleCommandAction(name, command)
}
return actions
}