Add comments

This commit is contained in:
Rob Dodson 2012-06-04 23:57:20 -07:00
parent b7dae81942
commit 31c251f6de
1 changed files with 10 additions and 7 deletions

17
app.js
View File

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