Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add long-polling setting and heroku support #263

Merged
merged 2 commits into from

2 participants

@badosu
Collaborator

Add the USE_POLLING environment setting and add the correspondent
description to the README of how to use it with CLIENT_PORT to set up
a dyno running subway.

Example: http://subway-chat.herokuapp.com/

Fix #255

@ericbarch ericbarch merged commit 6374800 into thedjpetersen:master
@badosu badosu deleted the badosu:long-polling-config branch
@badosu
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 10, 2013
  1. @badosu

    Add use_polling config

    badosu authored
  2. @badosu
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 1 deletion.
  1. +20 −0 README.md
  2. +3 −1 config.js
  3. +6 −0 lib/subway.js
View
20 README.md
@@ -45,6 +45,26 @@ Discussion about the client takes place on the freenode channel **#subway**, and
this repository's [Issues](https://github.com/thedjpetersen/subway/issues) page.
Contributors are welcome and greatly appreciated.
+Configuration
+-------------
+
+### Client Port
+
+You can set which port will be listened on the socket side with the
+`client_port` setting.
+
+### Long Polling
+
+If for some reasons you can't establish websockets, (e.g. Heroku, browser
+compatibility) specify the `use_polling` config for your app
+and it will use xhr-polling instead.
+
+### Heroku
+
+Set the following environment vars to your app:
+
+* USE\_POLLING=1
+* CLIENT\_PORT=80
History
-------
View
4 config.js
@@ -34,6 +34,8 @@ module.exports = {
client_port: 80 // Websockets talk on port 80 on Nodester, regardless of listen port
},
+ use_polling: process.env.USE_POLLING || false, // Use polling if websockets aren't supported
+
// limit each user's connection log to this amount of messages (***not implemented yet***)
max_log_size: 4096
-};
+};
View
6 lib/subway.js
@@ -37,6 +37,12 @@ Subway.prototype.start = function () {
// link up socket.io with our express app
instance.app.io = io.listen(server);
+ if (config.use_polling) {
+ instance.app.io.configure(function() {
+ instance.app.io.set("transports", ["xhr-polling"]);
+ instance.app.io.set("polling duration", 10);
+ });
+ }
// setup the IRC manager
require('./ircmanager')(app);
Something went wrong with that request. Please try again.