Not /that/ useful, but affords me some stats.

This commit is contained in:
Remy Sharp 2012-07-03 00:13:34 +01:00
parent 5df02abaa1
commit e32f37bd9a

View File

@ -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');