July 2019
Intermediate to advanced
416 pages
10h 6m
English
Imagine that we are writing a server that can be used by any number of client applications, and those client applications could be using any number of other Socket.IO servers as well. We could be introducing bugs into the client application if we use the same message names as the messages coming from the other Socket.IO servers. To circumvent this issue, Socket.IO uses a concept called namespaces to allow us to segregate our messages so that they don't conflict with other applications.
A namespace is a convenient way to provide a unique endpoint to connect to, and we connect to it using code that looks as follows:
const socket = io.of('/customSocket');socket.on('connection', function(socket) { ...});
This code should ...
Read now
Unlock full access