I spent a couple hours looking into this, and I could not find a definitive answer so I'm creating a question. I'm quite new to websockets, so apologies in advanced if the answer is easily available somewhere.
I currently have a node.js server emitting several different websocket events through socket.io. Throughout different parts of the server code, I therefore have lines that look like:
io.sockets.emit('eventOne', data);
Let's say that other parts of the code also include lines such as:
io.sockets.emit('eventTwo', data);
I have two different types of clients that connect to the server. One type of clients only listen to the first event, thus having lines such as:
socket.on('eventOne', function(data) {//blah blah}):
The other class of clients listen to the other event, and thus have run lines such as:
socket.on('eventTwo', function(data) {//blah blah});
Both clients are connected on root level without rooms. If we look at the first group of clients, for example, it's only watching for the 'eventOne' events, so it makes me wonder if this group of clients receive all the data for 'eventTwo' events, or if they do not because they do not listen for them.
Here's my ultimate question: Do the clients experience A: the full network load for all events, or B: only for events that they are watching for? (or C: full load for events that they are watching for and only partial load for events they do not watch for)
My guess is that even though the client side code are not watching for all events, all the emitted events from the server will be emitted through the websocket, and both types of clients will each be under network load for both types of events. However, a part of me thinks that socket.io code might reduce the network load for clients by refusing to receive the entire payload for events that they are not watching after it determines what the event is.
Yes, in this example, the two types of clients should be joining different rooms, but I just wanted to better understand how watching for events affects the network load
Thanks in advance for the insights!