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`.
So that the call to the `has-binary` method can be skipped. Usage:
```
// with binary data
socket.binary(true).emit("binary", obj);
// without binary data
socket.binary(false).emit("string", obj);
// call to hasBin
socket.emit("guess", obj);
```
Using a middleware could previously lead to a connecting client
receiving a connect event from the server before the server triggers
its own connect event.
That new flag will prevent the adapter (redis) from publishing the emit to the pub/sub server.
When several instances of a server receive the same event from a third party (not from a client), each server instance broadcasts the event to all his clients. With the local flag, and the change in the redis adapter, each server instance send the event only to his client, so each client receive only one unique event.
lib/namespace.js previously was not considering whether an event had
binary data and was giving all events parser.EVENT type -- now it uses
the has-binary-data module to set the event type appropriately.
Then, after this fix there was a problem with lib/adapter.js -- because
socket.io-parser modifies the packet object in its encoding, the sockets
after the 1st in a broadcast were not getting the correct data. To fix
this, the data is encoded once in adapter, and then the encoded data
is passed to each of the sockets.
lib/socket.js and lib/client.js were updated to allow for the above. The
.packet method of each now takes an optional second "preEncoded" parameter
-- if this is true, then client skips the encoding and just writes the
packet argument directly to engine.
test/socket.io.js was updated to add two new tests that test
multi-messaging of events with binary data.
Currently it's possible for a client do .emit('disconnect') and this will trigger
the disconnect event on the server.. Which can lead to major issues.
We should black list that by default. You can override or add more events by adding
them to the `blacklist` setting