From 31c251f6de585416d5caa823f51dc84330d666d9 Mon Sep 17 00:00:00 2001 From: Rob Dodson Date: Mon, 4 Jun 2012 23:57:20 -0700 Subject: [PATCH] Add comments --- app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 212c907..14a9af1 100644 --- a/app.js +++ b/app.js @@ -22,14 +22,17 @@ app.configure('production', function() { app.use(express.errorHandler()); }); -io.configure(function () { - io.set("transports", ["xhr-polling"]); - io.set("polling duration", 10); -}); +// Heroku won't actually allow us to use WebSockets +// so we have to setup polling instead. +// https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku +// io.configure(function () { +// io.set("transports", ["xhr-polling"]); +// io.set("polling duration", 10); +// }); // Routes -var port = process.env.PORT || 5000; +var port = process.env.PORT || 5000; // Use the port that Heroku provides or default to 5000 app.listen(port, function() { console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env); }); @@ -39,9 +42,9 @@ app.get('/', routes.index); var status = "All is well."; io.sockets.on('connection', function (socket) { - socket.emit('status', { status: status }); + io.sockets.emit('status', { status: status }); // note the use of io.sockets to emit but socket.on to listen socket.on('reset', function (data) { status = "War is imminent!"; - socket.emit('status', { status: status }); + io.sockets.emit('status', { status: status }); }); }); \ No newline at end of file