-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (27 loc) · 875 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
var express = require('express');
var path = require('path');
var http = require('http');
var app = express();
var server = http.Server(app);
var io = require('socket.io')(server);
var port = process.env.PORT || 3000;
var sup = require('./lib/sup')(io, port);
var heyThere = require('./lib/hey-there')(io);
app.use(express.static(path.join(__dirname, 'public')));
app.use('/hey-there', function(req, res){
res.sendfile('public/hey-there.html');
});
app.use('/', function(req, res){
res.sendfile('public/sup.html');
});
app.use('/sup', function(req, res){
res.sendfile('public/sup.html');
});
server.listen(port, function(){
console.log('server started, listening on port ' + port + '...');
});
io.on('connection', function(socket){
console.log('new client connected');
socket.on('sup', sup.saySup);
socket.on('status-update', heyThere.statusUpdate);
});