-
Notifications
You must be signed in to change notification settings - Fork 27
/
app.js
36 lines (29 loc) · 980 Bytes
/
app.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
var express = require('express'),
http = require('http'),
path = require('path'),
ioServer = require('socket.io'),
app = express(),
masterUser = 'username',
masterPass = 'password',
port = process.env.PORT || 3000;
app.configure(function () {
app.use(express.static(path.join(__dirname, 'public')));
});
// Authentication
var auth = express.basicAuth(masterUser, masterPass);
app.get('/', auth, function (req, res) {
res.sendfile(__dirname + '/views/index.html');
});
app.get('/client', function (req, res) {
res.sendfile(__dirname + '/views/client.html');
});
var server = http.createServer(app).listen(port, function () {
console.log("Express server listening on port "+port);
});
var io = ioServer.listen(server);
io.sockets.on('connection', function (socket) {
socket.emit("message", "Welcome to Revealer");
socket.on("slidechanged", function (data) {
socket.broadcast.emit("slidechanged", data);
});
});