File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -68,11 +68,21 @@ function adapter(uri, opts){
6868
6969 this . uid = uid ;
7070 this . prefix = prefix ;
71+ this . channel = prefix + '#' + nsp . name + '#' ;
72+ if ( String . prototype . startsWith ) {
73+ this . channelMatches = function ( messageChannel , subscribedChannel ) {
74+ return messageChannel . startsWith ( subscribedChannel ) ;
75+ }
76+ } else { // Fallback to slow indexOf impl for older Node.js
77+ this . channelMatches = function ( messageChannel , subscribedChannel ) {
78+ return messageChannel . indexOf ( subscribedChannel ) === 0 ;
79+ }
80+ }
7181 this . pubClient = pub ;
7282 this . subClient = sub ;
7383
7484 var self = this ;
75- sub . subscribe ( prefix + '#' + nsp . name + '#' , function ( err ) {
85+ sub . subscribe ( this . channel , function ( err ) {
7686 if ( err ) self . emit ( 'error' , err ) ;
7787 } ) ;
7888 sub . on ( subEvent , this . onmessage . bind ( this ) ) ;
@@ -91,6 +101,9 @@ function adapter(uri, opts){
91101 */
92102
93103 Redis . prototype . onmessage = function ( channel , msg ) {
104+ if ( ! this . channelMatches ( channel . toString ( ) , this . channel ) ) {
105+ return debug ( 'ignore different channel' ) ;
106+ }
94107 var args = msgpack . decode ( msg ) ;
95108 var packet ;
96109
You can’t perform that action at this time.
0 commit comments