@@ -49,6 +49,7 @@ function adapter(uri, opts){
49
49
var prefix = opts . key || 'socket.io' ;
50
50
var subEvent = opts . subEvent || 'message' ;
51
51
var requestsTimeout = opts . requestsTimeout || 1000 ;
52
+ var withChannelMultiplexing = false !== opts . withChannelMultiplexing ;
52
53
53
54
// init clients if needed
54
55
function createClient ( redis_opts ) {
@@ -79,6 +80,7 @@ function adapter(uri, opts){
79
80
this . uid = uid ;
80
81
this . prefix = prefix ;
81
82
this . requestsTimeout = requestsTimeout ;
83
+ this . withChannelMultiplexing = withChannelMultiplexing ;
82
84
83
85
this . channel = prefix + '#' + nsp . name + '#' ;
84
86
this . requestChannel = prefix + '-request#' + this . nsp . name + '#' ;
@@ -279,7 +281,7 @@ function adapter(uri, opts){
279
281
if ( ! ( remote || ( opts && opts . flags && opts . flags . local ) ) ) {
280
282
var self = this ;
281
283
var msg = msgpack . encode ( [ uid , packet , opts ] ) ;
282
- if ( opts . rooms ) {
284
+ if ( self . withChannelMultiplexing && opts . rooms ) {
283
285
opts . rooms . forEach ( function ( room ) {
284
286
var chnRoom = self . channel + room + '#' ;
285
287
pub . publish ( chnRoom , msg ) ;
@@ -304,6 +306,11 @@ function adapter(uri, opts){
304
306
debug ( 'adding %s to %s ' , id , room ) ;
305
307
var self = this ;
306
308
Adapter . prototype . add . call ( this , id , room ) ;
309
+
310
+ if ( ! this . withChannelMultiplexing ) {
311
+ if ( fn ) fn ( null ) ;
312
+ return ;
313
+ }
307
314
var channel = this . channel + room + '#' ;
308
315
sub . subscribe ( channel , function ( err ) {
309
316
if ( err ) {
@@ -331,7 +338,7 @@ function adapter(uri, opts){
331
338
var hasRoom = this . rooms . hasOwnProperty ( room ) ;
332
339
Adapter . prototype . del . call ( this , id , room ) ;
333
340
334
- if ( hasRoom && ! this . rooms [ room ] ) {
341
+ if ( this . withChannelMultiplexing && hasRoom && ! this . rooms [ room ] ) {
335
342
var channel = this . channel + room + '#' ;
336
343
sub . unsubscribe ( channel , function ( err ) {
337
344
if ( err ) {
0 commit comments