1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Convert pub/sub channel names into strings.

This commit is contained in:
Matt Ranney
2010-09-19 23:52:59 -07:00
parent 200ced827a
commit ed77cb4d95

View File

@@ -455,9 +455,9 @@ RedisClient.prototype.return_reply = function (reply) {
var type = reply[0].toString(); var type = reply[0].toString();
if (type === "message") { if (type === "message") {
this.emit("message", reply[1], reply[2]); // channel, message this.emit("message", reply[1].toString(), reply[2]); // channel, message
} else if (type === "pmessage") { } else if (type === "pmessage") {
this.emit("pmessage", reply[1], reply[2], reply[3]); // pattern, channel, message this.emit("pmessage", reply[1].toString(), reply[2].toString(), reply[3]); // pattern, channel, message
} else if (type === "subscribe" || type === "unsubscribe" || type === "psubscribe" || type === "punsubscribe") { } else if (type === "subscribe" || type === "unsubscribe" || type === "psubscribe" || type === "punsubscribe") {
if (reply[2] === 0) { if (reply[2] === 0) {
this.subscriptions = false; this.subscriptions = false;
@@ -465,7 +465,7 @@ RedisClient.prototype.return_reply = function (reply) {
console.log("All subscriptions removed, exiting pub/sub mode"); console.log("All subscriptions removed, exiting pub/sub mode");
} }
} }
this.emit(type, reply[1], reply[2]); // channel, count this.emit(type, reply[1].toString(), reply[2]); // channel, count
} else { } else {
throw new Error("subscriptions are active but got unknown reply type " + type); throw new Error("subscriptions are active but got unknown reply type " + type);
} }