Skip to content
Browse files

Reconnect when disconnected from a listening room. Fixes #1.

  • Loading branch information...
1 parent c0398f8 commit 4c20b6b00739d82208c184e01d26de941e440215 @tristandunn committed Mar 12, 2012
Showing with 16 additions and 13 deletions.
  1. +16 −13 lib/campfire/room.js
View
29 lib/campfire/room.js
@@ -42,20 +42,23 @@ Room.prototype.listen = function(callback) {
}
};
- campfire.http.request(options, function(response) {
- response.setEncoding("utf8");
- response.on("data", function(data) {
- data.split("\r").forEach(function(chunk) {
- try {
- var data = JSON.parse(chunk.trim());
- } catch(e) {
- return;
- }
-
- callback(new Message(campfire, data));
+ (function listen() {
+ campfire.http.request(options, function(response) {
+ response.setEncoding("utf8");
+ response.on("end", listen);
+ response.on("data", function(data) {
+ data.split("\r").forEach(function(chunk) {
+ try {
+ var data = JSON.parse(chunk.trim());
+ } catch(e) {
+ return;
+ }
+
+ callback(new Message(campfire, data));
+ });
});
- });
- }).end();
+ }).end();
+ })();
};
Room.prototype.lock = function(callback) {

0 comments on commit 4c20b6b

Please sign in to comment.
Something went wrong with that request. Please try again.