Skip to content

Commit 9c3616e

Browse files
[refactor] Use this.channel to construct the name of a channel (#129)
1 parent 6350633 commit 9c3616e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ function adapter(uri, opts){
187187
Redis.prototype.broadcast = function(packet, opts, remote){
188188
packet.nsp = this.nsp.name;
189189
if (!remote) {
190-
var chn = prefix + '#' + packet.nsp + '#';
190+
var self = this;
191191
var msg = msgpack.encode([uid, packet, opts]);
192192
if (opts.rooms) {
193193
opts.rooms.forEach(function(room) {
194-
var chnRoom = chn + room + '#';
194+
var chnRoom = self.channel + room + '#';
195195
pub.publish(chnRoom, msg);
196196
});
197197
} else {
198-
pub.publish(chn, msg);
198+
pub.publish(self.channel, msg);
199199
}
200200
}
201201
Adapter.prototype.broadcast.call(this, packet, opts);
@@ -214,7 +214,7 @@ function adapter(uri, opts){
214214
debug('adding %s to %s ', id, room);
215215
var self = this;
216216
Adapter.prototype.add.call(this, id, room);
217-
var channel = prefix + '#' + this.nsp.name + '#' + room + '#';
217+
var channel = this.channel + room + '#';
218218
sub.subscribe(channel, function(err){
219219
if (err) {
220220
self.emit('error', err);
@@ -242,7 +242,7 @@ function adapter(uri, opts){
242242
Adapter.prototype.del.call(this, id, room);
243243

244244
if (hasRoom && !this.rooms[room]) {
245-
var channel = prefix + '#' + this.nsp.name + '#' + room + '#';
245+
var channel = this.channel + room + '#';
246246
sub.unsubscribe(channel, function(err){
247247
if (err) {
248248
self.emit('error', err);

0 commit comments

Comments
 (0)