display active connections
This commit is contained in:
parent
1d8acbbd72
commit
232f9d5b47
3 changed files with 20 additions and 8 deletions
|
@ -583,6 +583,9 @@ img {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active-connections {
|
||||||
|
color: #999
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
14
server.js
14
server.js
|
@ -32,14 +32,24 @@ server.listen(port);
|
||||||
|
|
||||||
console.log('Server running at http://127.0.0.1:' + port + '/');
|
console.log('Server running at http://127.0.0.1:' + port + '/');
|
||||||
|
|
||||||
|
/**************
|
||||||
|
SETUP Socket.IO
|
||||||
|
**************/
|
||||||
|
var io = require('socket.io')(server);
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
ROUTES
|
ROUTES
|
||||||
**************/
|
**************/
|
||||||
app.get('/', function(req, res) {
|
app.get('/', function(req, res) {
|
||||||
//console.log(req.header('host'));
|
//console.log(req.header('host'));
|
||||||
url = req.header('host');
|
url = req.header('host');
|
||||||
|
|
||||||
|
var connected = io.sockets.connected;
|
||||||
|
clientsCount = Object.keys(connected).length;
|
||||||
|
|
||||||
res.render('home.jade', {
|
res.render('home.jade', {
|
||||||
url: url
|
url: url,
|
||||||
|
connected: clientsCount
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,8 +71,6 @@ app.get('/:id', function(req, res){
|
||||||
/**************
|
/**************
|
||||||
SOCKET.I0
|
SOCKET.I0
|
||||||
**************/
|
**************/
|
||||||
var io = require('socket.io')(server);
|
|
||||||
|
|
||||||
io.sockets.on('connection', function (client) {
|
io.sockets.on('connection', function (client) {
|
||||||
//santizes text
|
//santizes text
|
||||||
function scrub( text ) {
|
function scrub( text ) {
|
||||||
|
|
|
@ -52,6 +52,7 @@ body
|
||||||
|
|
||||||
|
|
||||||
//display # of active users here
|
//display # of active users here
|
||||||
|
div.active-connections= "connections: " + connected
|
||||||
|
|
||||||
//<div style="width: 980px; height: 450px; border: solid 2px; opacity:.1; margin-top: 100px"> this will be the backlog that only appears on drag or perhaps not at all</div>
|
//<div style="width: 980px; height: 450px; border: solid 2px; opacity:.1; margin-top: 100px"> this will be the backlog that only appears on drag or perhaps not at all</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue