Skip to content

Commit

Permalink
[fix] Throw an error when trying to access the clients of a dynamic n…
Browse files Browse the repository at this point in the history
…amespace (#3355)

Accessing the clients of a dynamic namespace throws because doing `io.of(/your-regex/g)` returns a namespace with no adapter and the clients methods tries to access `namespace.adapter.clients`.
  • Loading branch information
0xClpz authored and darrachequesne committed Nov 20, 2018
1 parent 190d22b commit a7fbd1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/namespace.js
Expand Up @@ -262,6 +262,9 @@ Namespace.prototype.write = function(){
*/

Namespace.prototype.clients = function(fn){
if(!this.adapter){
throw new Error('No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?')
}
this.adapter.clients(this.rooms, fn);
// reset rooms for scenario:
// .in('room').clients() (GH-1978)
Expand Down

0 comments on commit a7fbd1a

Please sign in to comment.