From 232f9d5b47c4a640ef5e2d65d180cf6ece81ef0e Mon Sep 17 00:00:00 2001 From: ali asaria Date: Tue, 30 Sep 2014 08:22:53 -0400 Subject: [PATCH] display active connections --- client/css/style.css | 3 +++ server.js | 14 +++++++++++--- views/home.jade | 11 ++++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/client/css/style.css b/client/css/style.css index 5b860f0..61c6d59 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -583,6 +583,9 @@ img { text-align: right; } +.active-connections { + color: #999 +} diff --git a/server.js b/server.js index 21ff5c9..6f86bb9 100644 --- a/server.js +++ b/server.js @@ -32,14 +32,24 @@ server.listen(port); console.log('Server running at http://127.0.0.1:' + port + '/'); +/************** + SETUP Socket.IO +**************/ +var io = require('socket.io')(server); + /************** ROUTES **************/ app.get('/', function(req, res) { //console.log(req.header('host')); url = req.header('host'); + + var connected = io.sockets.connected; + clientsCount = Object.keys(connected).length; + res.render('home.jade', { - url: url + url: url, + connected: clientsCount }); }); @@ -61,8 +71,6 @@ app.get('/:id', function(req, res){ /************** SOCKET.I0 **************/ -var io = require('socket.io')(server); - io.sockets.on('connection', function (client) { //santizes text function scrub( text ) { diff --git a/views/home.jade b/views/home.jade index 04ff145..8b7170f 100644 --- a/views/home.jade +++ b/views/home.jade @@ -15,11 +15,11 @@ body div.board-outline div#board div#board-doodles - - + + table#board-table.board-table tr - td + td h1.home scrumblr. form.home(onsubmit="return go();") label name your new board: @@ -31,7 +31,7 @@ body p.home!= '' + locals.url + '/demo'


p.home.small sourcecode at github - + div.stickers div.sticker#sticker-red image(src="/images/stickers/sticker-red.png") @@ -52,9 +52,10 @@ body //display # of active users here + div.active-connections= "connections: " + connected //
this will be the backlog that only appears on drag or perhaps not at all
- \ No newline at end of file +