-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (33 loc) · 1.01 KB
/
server.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
var app = require('express').createServer(),
io = require('socket.io').listen(app),
osc = require('node-osc'),
client = new osc.Client('0.0.0.0', 3333),
mdns = require('mdns');
app.listen(1337);
// advertise a http server on port 1337
var ad = mdns.createAdvertisement(mdns.tcp('http'), 1337);
ad.start();
app.get('/', function (req, res) {
res.sendfile(__dirname + '/public/index.html');
});
// app.get('/piano', function (req, res) {
// res.sendfile(__dirname + '/public/piano.html');
// });
app.get('/*.(js|css|jpg)', function(req, res){
res.sendfile("./public"+req.url);
});
io.sockets.on('connection', function (socket) {
socket.on('xy', function (data) {
client.send("/x", data[0]);
client.send("/y", data[1]);
});
socket.on('alpha', function (data) {
client.send("/alpha", data);
});
socket.on('beta', function (data) {
client.send("/beta", data);
});
socket.on('gamma', function (data) {
client.send("/gamma", data);
});
});