Skip to content

Commit

Permalink
Merge pull request redis#190 from bnoguchi/pub_sub_mode-fix
Browse files Browse the repository at this point in the history
Pub sub mode fix
  • Loading branch information
mranney committed Apr 30, 2012
2 parents 38e38c5 + 64a0e68 commit 9e76387
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ RedisClient.prototype.return_reply = function (reply) {
if (this.debug_mode) {
console.log("All subscriptions removed, exiting pub/sub mode");
}
} else {
this.pub_sub_mode = true;
}
// subscribe commands take an optional callback and also emit an event, but only the first response is included in the callback
// TODO - document this or fix it so it works in a more obvious way
Expand Down
14 changes: 14 additions & 0 deletions tests/re_sub_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var client = require('../index').createClient()
, client2 = require('../index').createClient()
, assert = require('assert');

client.once('subscribe', function (channel, count) {
client.unsubscribe('x');
client.subscribe('x', function () {
client.quit();
client2.quit();
});
client2.publish('x', 'hi');
});

client.subscribe('x');

0 comments on commit 9e76387

Please sign in to comment.