From 9cd74e7695afe5ec01a4bfe275d7a5a15d7db666 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 26 Sep 2016 02:45:23 +0200 Subject: [PATCH] =?UTF-8?q?[refactor]=C2=A0Use=20this.channel=20to=20const?= =?UTF-8?q?ruct=20the=20name=20of=20a=20channel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 8e2d21d..7fb52c2 100644 --- a/index.js +++ b/index.js @@ -187,15 +187,15 @@ function adapter(uri, opts){ Redis.prototype.broadcast = function(packet, opts, remote){ packet.nsp = this.nsp.name; if (!remote) { - var chn = prefix + '#' + packet.nsp + '#'; + var self = this; var msg = msgpack.encode([uid, packet, opts]); if (opts.rooms) { opts.rooms.forEach(function(room) { - var chnRoom = chn + room + '#'; + var chnRoom = self.channel + room + '#'; pub.publish(chnRoom, msg); }); } else { - pub.publish(chn, msg); + pub.publish(self.channel, msg); } } Adapter.prototype.broadcast.call(this, packet, opts); @@ -214,7 +214,7 @@ function adapter(uri, opts){ debug('adding %s to %s ', id, room); var self = this; Adapter.prototype.add.call(this, id, room); - var channel = prefix + '#' + this.nsp.name + '#' + room + '#'; + var channel = this.channel + room + '#'; sub.subscribe(channel, function(err){ if (err) { self.emit('error', err); @@ -242,7 +242,7 @@ function adapter(uri, opts){ Adapter.prototype.del.call(this, id, room); if (hasRoom && !this.rooms[room]) { - var channel = prefix + '#' + this.nsp.name + '#' + room + '#'; + var channel = this.channel + room + '#'; sub.unsubscribe(channel, function(err){ if (err) { self.emit('error', err);