-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (26 loc) · 711 Bytes
/
index.js
File metadata and controls
30 lines (26 loc) · 711 Bytes
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
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.use(express.static(__dirname + '/static'));
io.on('connection', function(socket) {
console.log('new user');
socket.on('setup', function(data) {
io.emit('setup', data);
console.log(data);
});
socket.on('setup complete', function(data) {
io.emit('setup complete', data);
console.log(data);
});
socket.on('game', function(data) {
io.emit('game', data);
console.log(data);
});
});
http.listen(8080,function() {
console.log('listening on port 8080');
});