You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Fix for channel names with spaces. Fixes #691
Channel names with spaces were not properly resubscribed after a reconnection. Conflicts: index.js
This commit is contained in:
committed by
Ruben Bridgewater
parent
b35a685c27
commit
97db227a8d
3
index.js
3
index.js
@@ -308,7 +308,8 @@ RedisClient.prototype.on_ready = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Object.keys(this.subscription_set).forEach(function (key) {
|
Object.keys(this.subscription_set).forEach(function (key) {
|
||||||
var parts = key.split(" ");
|
var space_index = key.indexOf(" ");
|
||||||
|
var parts = [key.slice(0, space_index), key.slice(space_index + 1)];
|
||||||
debug("Sending pub/sub on_ready " + parts[0] + ", " + parts[1]);
|
debug("Sending pub/sub on_ready " + parts[0] + ", " + parts[1]);
|
||||||
callback_count++;
|
callback_count++;
|
||||||
self.send_command(parts[0] + "scribe", [parts[1]], callback);
|
self.send_command(parts[0] + "scribe", [parts[1]], callback);
|
||||||
|
@@ -43,14 +43,22 @@ describe("publish/subscribe", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('subscribe', function () {
|
describe('subscribe', function () {
|
||||||
it('fires a subscribe event for each channel subscribed to', function (done) {
|
it('fires a subscribe event for each channel subscribed to even after reconnecting', function (done) {
|
||||||
|
var a = false;
|
||||||
sub.on("subscribe", function (chnl, count) {
|
sub.on("subscribe", function (chnl, count) {
|
||||||
if (chnl === channel2) {
|
if (chnl === channel2) {
|
||||||
assert.equal(2, count);
|
assert.equal(2, count);
|
||||||
return done();
|
if (a) {
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
sub.stream.destroy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sub.on('reconnecting', function() {
|
||||||
|
a = true;
|
||||||
|
});
|
||||||
|
|
||||||
sub.subscribe(channel, channel2);
|
sub.subscribe(channel, channel2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user