Open
Description
https://socket.io/docs/v4/server-api/ shows some examples of .e.g io.use()
, but it never explains what they are.
https://socket.io/docs/v4/namespaces/#main-namespace explains that all those versions are interacting with the main namespace:
io.on("connection", (socket) => {});
io.use((socket, next) => { next() });
io.emit("hello");
// are actually equivalent to
io.of("/").on("connection", (socket) => {});
io.of("/").use((socket, next) => { next() });
io.of("/").emit("hello");
A section in the Server API docs should preferably document all these, as they are part of the API of io
but never explained there.
(If I could chose, I would in version 5 actually remove the direct usage of those and only allow io.of()
as I believe explicit-over-implicit is good in this case and also simplifies a lot of documentation and explanation around this. But that is highly subjective and I am sure others like the shortcuts).