-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
85 lines (61 loc) · 1.78 KB
/
app.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
var express = require('express');
var http = require('http');
var app = express();
var server = http.createServer(app);
var io = require('socket.io')(server);
var path = require('path');
app.use(express.static(path.join(__dirname,'./public')));
app.get('/', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.get('/terminal', (req, res) => {
res.sendFile(__dirname + '/public/terminal.html');
})
//------ Serve to PCs -------//
app.get('/jack', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.get('/jessie', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.get('/corny', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.get('/kaiden', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
// ------ Serve to myself -----
app.get('/dm', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.get('/checks', (req, res) => {
res.sendFile(__dirname + '/public/checks.html');
})
io.on('connection', (socket) => {
console.log('new user connected');
socket.on('disconnect', () => {
console.log('user disconnected');
});
socket.on('change', (loc) => {
socket.broadcast.emit('change', loc);
//sending message to all except the sender
});
socket.on('visibility', (d) => {
socket.broadcast.emit('visibility', d);
})
socket.on('darkness', (d) => {
socket.broadcast.emit('darkness', d);
})
socket.on('toggle', (d) => {
socket.broadcast.emit('toggle', d);
})
socket.on('cutoff', (d) => {
socket.broadcast.emit('cutoff', d);
})
socket.on('togglecam', (d) => {
socket.broadcast.emit('togglecam', d);
})
});
server.listen(process.env.PORT || 3000, () => {
console.log('Server listening on :3000');
});