Skip to content Skip to sidebar Skip to footer

Why Is The Broadcast Described As Flag In The Docs When It Is Actually An Object?

In the broadcasting messages section http://socket.io/docs/#broadcasting-messages there is the following description To broadcast, simply add a broadcast flag to emit and send met

Solution 1:

Internally in the socket.io implementation, broadcast is a flag that is sent with an emit that tells the underlying infrastructure what to do. See the source for that flag here and you can see here in the source where it tests for that flag on a socket to decide if a given emit should be broadcast.

The broadcast in socket.broadcast.emit() is indeed an object.

broadcast is also a method on the adapter object which is used internally by socket.io. So, they've used the term for just about everything (flag, object, method). The doc has a few of the different uses confused in the case you reference.

The socket.io doc is what it is (not nearly as good as it could be). I find constant references to the source code on Github or even tracing into the execution in a debugger to be essential for understanding how things work.


Post a Comment for "Why Is The Broadcast Described As Flag In The Docs When It Is Actually An Object?"