-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (43 loc) · 1.37 KB
/
index.js
File metadata and controls
61 lines (43 loc) · 1.37 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
var express = require('express');
var app = express();
app.use(express.static('public'));
app.use('/samples', express.static('samples'));
app.get('/' , function(req, res) {
res.redirect('/drum.html');
})
var http = require('http').Server(app);
var io = require('socket.io')(http);
http.listen(8080, function() {
console.log('listening on *:8080');
})
io.on('connection', function(socket) {
console.log('a user connected');
socket.on('disconnect', function() {
console.log('a user disconnected');
});
socket.on('note', function(msg) {
console.log('a drum note setting has arrived: ' +msg);
// io.emit('drum', msg);
socket.broadcast.emit('note', msg);
});
socket.on('sound', function(msg) {
console.log('a new sound has arrived: ' +msg);
// io.emit('drum', msg);
socket.broadcast.emit('sound', msg);
});
socket.on('presound', function(msg) {
console.log('load preset: ' +msg);
// io.emit('drum', msg);
socket.broadcast.emit('presound', msg);
});
socket.on('tempo', function(msg) {
// console.log('tempo change: ' +msg);
// io.emit('drum', msg);
socket.broadcast.emit('tempo', msg);
});
socket.on('sync', function(msg) {
console.log('sync');
socket.broadcast.emit('sync');
socket.emit('sync');
});
});