forked from patcat/Leap-Motion-Call-Controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (33 loc) · 1011 Bytes
/
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
var http = require('http'),
express = require('express'),
app = express(),
server = require('http').createServer(app),
port = process.env.PORT || 5000,
call = {};
call.sound = true;
app.use(express.bodyParser());
app.get('/', function(request, response) {
response.sendfile('public/index.html');
});
app.post('/shouldibesilent', function(request, response) {
console.log('That phone wants to know if it should be silent...', request);
response.json({callSound: call.sound});
});
app.post('/call', function(request, response) {
console.log('Something is setting the call to ' + request.body.action);
switch (request.body.action) {
case 'mute':
call.sound = false;
break;
case 'reset':
call.sound = true;
break;
}
response.json({success: true, actionReceived: request.body.action});
});
app.get(/^(.+)$/, function(req, res) {
res.sendfile('public/' + req.params[0]);
});
server.listen(port, function() {
console.log('Listening on ' + port);
});