Skip to content

Commit 8dd84c7

Browse files
[fix] Fix broken protocol in 5.0.0 (#221)
The message is now published to `socket.io#<namespace>#<my-room>#` channel, instead of `socket.io#<namespace>#<my-room>`.
1 parent 5f475fb commit 8dd84c7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function adapter(uri, opts) {
140140
return debug('ignore different channel');
141141
}
142142

143-
var room = channel.substring(this.channel.length);
143+
var room = channel.slice(this.channel.length, -1);
144144
if (room !== '' && !this.rooms.hasOwnProperty(room)) {
145145
return debug('ignore unknown room %s', room);
146146
}
@@ -404,11 +404,12 @@ function adapter(uri, opts) {
404404
packet.nsp = this.nsp.name;
405405
if (!(remote || (opts && opts.flags && opts.flags.local))) {
406406
var msg = msgpack.encode([uid, packet, opts]);
407+
var channel = this.channel;
407408
if (opts.rooms && opts.rooms.length === 1) {
408-
pub.publish(this.channel + opts.rooms[0], msg);
409-
} else {
410-
pub.publish(this.channel, msg);
409+
channel += opts.rooms[0] + '#';
411410
}
411+
debug('publishing message to channel %s', channel);
412+
pub.publish(channel, msg);
412413
}
413414
Adapter.prototype.broadcast.call(this, packet, opts);
414415
};

0 commit comments

Comments
 (0)