-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
93 lines (78 loc) · 2.29 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
const Atem = require('atem')
const myAtem = new Atem()
const { config } = require('dotenv');
const path = require("path");
config();
var atemStatus = {
PROGRAM: 0,
PREVIEW: 0
};
app.use('/res', express.static('client'));
app.use("/node_modules", express.static(path.join(__dirname, '/node_modules/')));
app.get('/', (req, res) => {
res.sendFile(__dirname + '/client/qrcode.html');
});
app.get('/monitor', (req, res) => {
res.sendFile(__dirname + '/client/index.html');
});
const sockets = []
io.on('connection', (socket) => {
// client connected
console.log('A user connected with socket id: ' + socket.id);
sockets[socket.id] = {}
// client disconnected
socket.on('disconnect', () => {
delete sockets[socket.id];
console.log(socket.id + ' disconnected');
});
// client typed name and camera no
socket.on('joinCamera', (data) => {
console.log("Socket " + data.id + "'s name is " + data.name + ", linked to camera #" + data.cameraId);
sockets[data.id] = { name: data.name, cameraId: data.cameraId }
sendStatus();
// send streaming
socket.emit("streaming", process.env.STREAMING_URL);
});
});
server.listen(3000, () => {
console.log('TallySystem app is running on *:3000');
});
// ATEM Integration
// Atem Device
myAtem.on('connectionStateChange', function(state) {
console.log('state', state);
});
myAtem.on('productNameChange', function(name) {
console.log('name', name);
});
myAtem.on('connectionLost', function(state) {
console.log('lost', state);
});
myAtem.on('error', function(state) {
console.error('error', state);
});
myAtem.on('programBus', function(source) {
atemStatus.PROGRAM = source;
sendStatus();
console.log('program bus changed to', source);
});
myAtem.on('previewBus', function(source) {
atemStatus.PREVIEW = source;
sendStatus();
console.log('program bus changed to', source);
});
myAtem.ip = process.env.ATEM_IP;
myAtem.connect();
function sendStatus(){
io.emit("cameraUpdate", atemStatus);
}
setTimeout(function(){
atemStatus.PROGRAM = 1;
sendStatus();
}, 20000)