-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (48 loc) · 1.47 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
const fs = require('fs')
const path = require('path')
const { AtemSocket } = require('atem-connection/dist/lib/atemSocket')
const { DEFAULT_PORT } = require('atem-connection')
const prompt = require('prompt');
prompt.start();
const properties = [
{
name: 'ip',
description: 'Enter the ip of your atem',
},
{
name: 'filename',
description: 'Enter the name of this case (eg. mini-v8.1)',
}
];
prompt.get(properties, function (err, result) {
if (err) { return onErr(err); }
console.log('starting');
const socket = new AtemSocket({
debug: false,
log: console.log,
disableMultithreaded: true,
address: result.ip,
port: DEFAULT_PORT
})
socket.on('disconnect', () => {
console.log('disconnect')
process.exit(1)
})
const output = []
socket.on('commandsReceived', cmds => {
const initComplete = cmds.find(cmd => cmd.constructor.name === 'InitCompleteCommand')
if (initComplete) {
console.log('complete')
const filePath = path.resolve(__dirname, `./${result.filename}.data`)
fs.writeFileSync(filePath, output.join('\n'))
process.exit(0)
}
})
const origParse = (socket._parseCommands).bind(socket)
socket._parseCommands = (payload) => {
output.push(payload.toString('hex'))
return origParse(payload)
}
socket.connect()
console.log('connecting')
});