@@ -49,6 +49,7 @@ function adapter(uri, opts){
4949 var prefix = opts . key || 'socket.io' ;
5050 var subEvent = opts . subEvent || 'message' ;
5151 var requestsTimeout = opts . requestsTimeout || 1000 ;
52+ var withChannelMultiplexing = false !== opts . withChannelMultiplexing ;
5253
5354 // init clients if needed
5455 function createClient ( redis_opts ) {
@@ -79,6 +80,7 @@ function adapter(uri, opts){
7980 this . uid = uid ;
8081 this . prefix = prefix ;
8182 this . requestsTimeout = requestsTimeout ;
83+ this . withChannelMultiplexing = withChannelMultiplexing ;
8284
8385 this . channel = prefix + '#' + nsp . name + '#' ;
8486 this . requestChannel = prefix + '-request#' + this . nsp . name + '#' ;
@@ -279,7 +281,7 @@ function adapter(uri, opts){
279281 if ( ! ( remote || ( opts && opts . flags && opts . flags . local ) ) ) {
280282 var self = this ;
281283 var msg = msgpack . encode ( [ uid , packet , opts ] ) ;
282- if ( opts . rooms ) {
284+ if ( self . withChannelMultiplexing && opts . rooms ) {
283285 opts . rooms . forEach ( function ( room ) {
284286 var chnRoom = self . channel + room + '#' ;
285287 pub . publish ( chnRoom , msg ) ;
@@ -304,6 +306,11 @@ function adapter(uri, opts){
304306 debug ( 'adding %s to %s ' , id , room ) ;
305307 var self = this ;
306308 Adapter . prototype . add . call ( this , id , room ) ;
309+
310+ if ( ! this . withChannelMultiplexing ) {
311+ if ( fn ) fn ( null ) ;
312+ return ;
313+ }
307314 var channel = this . channel + room + '#' ;
308315 sub . subscribe ( channel , function ( err ) {
309316 if ( err ) {
@@ -331,7 +338,7 @@ function adapter(uri, opts){
331338 var hasRoom = this . rooms . hasOwnProperty ( room ) ;
332339 Adapter . prototype . del . call ( this , id , room ) ;
333340
334- if ( hasRoom && ! this . rooms [ room ] ) {
341+ if ( this . withChannelMultiplexing && hasRoom && ! this . rooms [ room ] ) {
335342 var channel = this . channel + room + '#' ;
336343 sub . unsubscribe ( channel , function ( err ) {
337344 if ( err ) {
0 commit comments