-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (30 loc) · 885 Bytes
/
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
var express = require('express')
, app = express.createServer()
, io = require('socket.io').listen(app);
app.use(express.bodyParser());
app.use('/public', express.static( __dirname + '/public'));
app.listen(8888);
io.configure(function () {
io.set('transports', ['websocket']);
io.set('log level', 1);
});
app.get('/', function (req, res) {
res.sendfile(__dirname + '/mobile.html');
});
app.get('/player', function(req, res) {
res.sendfile(__dirname + '/player.html');
});
app.get('/room', function(req, res) {
res.sendfile(__dirname + '/room.html');
});
io.of('/publish').
on('connection', function (socket) {
console.log('Publisher connected');
socket.on('update', function (data) {
io.of('/subscribe').emit('update', data);
});
});
io.of('/subscribe').
on('connection', function(socket) {
console.log('Subscriber connected');
});