diff --git a/lib/spike/index.js b/lib/spike/index.js index 5d9cbf67..321fbbf4 100644 --- a/lib/spike/index.js +++ b/lib/spike/index.js @@ -78,7 +78,7 @@ module.exports = { clearTimeout(pending[id].timer); - // NOTE: this will only fire once per jsbin session - + // NOTE: this will only fire once per jsbin session - // not for every panel sent - because we clear the timer pending[id].timer = setTimeout(function () { var session = sessionForBin(bin), @@ -104,6 +104,7 @@ module.exports = { if (data) { session.res.forEach(function (res) { res.write('data:' + data.content.split('\n').join('\ndata:') + '\nevent:' + data.panelId + '\n\n'); + res.write('event: stats\ndata: ' + JSON.stringify({ connections: session.res.length }) + '\n\n'); if (res.ajax) { res.end(); // lets older browsers finish their xhr request } @@ -113,7 +114,7 @@ module.exports = { }, delayTrigger); }, appendScripts: function (scripts) { - // TODO this should really detect that there's an active session going + // TODO this should really detect that there's an active session going // on and the user is saving, and therefore include the spike intelligently scripts.push('js/vendor/eventsource.js'); scripts.push('js/spike.js');