-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·38 lines (32 loc) · 904 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
const express = require('express');
const app = express();
const http = require('http').createServer(app);
const io = require('socket.io')(http);
const PORT = process.env.PORT || 3000;
app.use(express.static(__dirname + '/public'));
app.get('/' , function(req, res){
res.sendFile(__dirname+'/index.html');
});
app.get('/view' , function(req, res){
res.sendFile(__dirname+'/view.html');
});
app.get('/control', function(req, res){
res.sendFile(__dirname+'/control.html');
});
io.on('connection',function(socket){
socket.on('name',function(name){
io.emit('name', name);
});
socket.on('left',function(left){
io.emit('left', left);
});
socket.on('right',function(right){
io.emit('right', right);
});
socket.on('reset', function(reset){
io.emit('reset', reset);
});
});
http.listen(PORT, function(){
console.log(PORT);
});