summaryrefslogtreecommitdiffstats
path: root/index.js
blob: b4d50e14054484e723eb0c73173e9803ce27d343 (plain)
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
39
40
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var que = []

app.get('/', function(req, res){
  res.sendFile(__dirname + '/f/templates/index.html');
});
app.get('/adm', function(req, res){
  res.sendFile(__dirname + '/f/templates/adm.html');
});

//route all paths beginning with /f/ to real files 
app.get('/f/*', function(req, res){
  res.sendFile(__dirname + req.path);
});


io.on('connection', function(socket){
  socket.emit("quedata",que);
   
  socket.on("queadd",function(data){
		console.log("adding new que entry");
  	que.push(data);
		io.emit("quedata",que);
  });
	socket.on("quepopfirst",function(data){
		console.log("deleting first from que");
  	que.shift();
		io.emit("quedata",que);
  });



});

http.listen(3000, function(){
  console.log('listening on *:3000');
});