What is the difference between a socket that just emits and one that is unstable?

This is the following question to the question below:

Why is this function updateSockets () accepts a parameter that looks like this:

In the code below, the socket uses volatile to emit.

var updateSockets = function(data) { // adding the time of the last update data.time = new Date(); console.log('Pushing new data to the clients connected ( connections amount = %s ) - %s', connectionsArray.length , data.time); // sending new data to all the sockets connected connectionsArray.forEach(function(tmpSocket) { tmpSocket.volatile.emit('notification', data); }); }; 

What to do if the code is changed so that it becomes tmpSocket.emit('notification', data); ? What is the difference between tmpSocket.volatile.emit('notification', data); and tmpSocket.emit('notification', data); ?

+6
source share
1 answer

From Socket.io docs :

Sending mutable messages

Sometimes some messages may be deleted. Let's say you have an application that shows real-time tweets for the Bieber keyword.

If a particular client is not ready to receive messages (due to network slowness or other problems, or because they are connected through a lengthy survey and are in the middle of a request-response cycle), if they do not receive ALL tweets related to your application’s bieber, .

In this case, you can send these messages as mutable messages.

Essentially, if you don't care if the client receives the data, then send it as mutable.

+5
source

All Articles