What is the difference between a socket that simply emits and one that volatile emits?

user781486

This is a follow-up question to the question below;

Why does this updateSockets() function accept a parameter that look 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 if the code is changed such that it becomes tmpSocket.emit('notification', data);? What is the difference between tmpSocket.volatile.emit('notification', data); and tmpSocket.emit('notification', data);?

SlashmanX

From the Socket.io docs:

Sending volatile messages

Sometimes certain messages can be dropped. Let’s say you have an app that shows realtime tweets for the keyword bieber.

If a certain client is not ready to receive messages (because of network slowness or other issues, or because they’re connected through long polling and is in the middle of a request-response cycle), if they doesn’t receive ALL the tweets related to bieber your application won’t suffer.

In that case, you might want to send those messages as volatile messages.

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Observable only emits one value?

From Dev

socket.io emits multiple times

From Dev

Socket.IO emitting for each client when only one client emits

From Dev

Create a signal that emits one object then completes?

From Dev

Create a signal that emits one object then completes?

From Dev

CAEmitterCell emits in two opposite orientation (one is wrong)

From Dev

Combining 2 Observables so that one emits the next value only when the second emits

From Dev

Socket.IO: Are Emits from clients to the server private

From Dev

NodeJs: Never emits "end" when reading a TCP Socket

From Dev

Socket.io - io.to.emit emits to all connected users

From Dev

What is the difference between the volatile modifier and Volatile.Read/Write?

From Dev

What is the difference between a packet and a socket?

From Dev

RXJava - buffer observable 1 until observable 2 emits one item

From Dev

What is the difference between lscpu Socket and networking Socket?

From Dev

Every that emits several times?

From Dev

Difference between Volatile and synchronized

From Dev

What is the difference between .one() and .first()

From Dev

What is the difference between Socket.IO and Firebase?

From Dev

What is difference between WebSockets and Socket.io?

From Dev

Express with Socket.IO: Server doesn't receive emits from client

From Dev

Transform SignalProducer that emits arrays to SignalProducer that emits all elements of the original array

From Dev

Transform SignalProducer that emits arrays to SignalProducer that emits all elements of the original array

From Dev

Vue Composition API: Defining emits

From Dev

AFNetworkReachabilityManager only emits RACSignal once

From Dev

What is the difference between socket.send() and socket.sendall()?

From Dev

Difference between volatile Boolean and Boolean

From Dev

What's the difference between adding Java Script libraries as npm dependencies or simply including them in HTML?

From Dev

What is the difference between Adding ICollection and Simply adding a field to store a key to another table?

From Dev

What's the effective difference between redirecting to /dev/null and simply closing the stream

Related Related

  1. 1

    Observable only emits one value?

  2. 2

    socket.io emits multiple times

  3. 3

    Socket.IO emitting for each client when only one client emits

  4. 4

    Create a signal that emits one object then completes?

  5. 5

    Create a signal that emits one object then completes?

  6. 6

    CAEmitterCell emits in two opposite orientation (one is wrong)

  7. 7

    Combining 2 Observables so that one emits the next value only when the second emits

  8. 8

    Socket.IO: Are Emits from clients to the server private

  9. 9

    NodeJs: Never emits "end" when reading a TCP Socket

  10. 10

    Socket.io - io.to.emit emits to all connected users

  11. 11

    What is the difference between the volatile modifier and Volatile.Read/Write?

  12. 12

    What is the difference between a packet and a socket?

  13. 13

    RXJava - buffer observable 1 until observable 2 emits one item

  14. 14

    What is the difference between lscpu Socket and networking Socket?

  15. 15

    Every that emits several times?

  16. 16

    Difference between Volatile and synchronized

  17. 17

    What is the difference between .one() and .first()

  18. 18

    What is the difference between Socket.IO and Firebase?

  19. 19

    What is difference between WebSockets and Socket.io?

  20. 20

    Express with Socket.IO: Server doesn't receive emits from client

  21. 21

    Transform SignalProducer that emits arrays to SignalProducer that emits all elements of the original array

  22. 22

    Transform SignalProducer that emits arrays to SignalProducer that emits all elements of the original array

  23. 23

    Vue Composition API: Defining emits

  24. 24

    AFNetworkReachabilityManager only emits RACSignal once

  25. 25

    What is the difference between socket.send() and socket.sendall()?

  26. 26

    Difference between volatile Boolean and Boolean

  27. 27

    What's the difference between adding Java Script libraries as npm dependencies or simply including them in HTML?

  28. 28

    What is the difference between Adding ICollection and Simply adding a field to store a key to another table?

  29. 29

    What's the effective difference between redirecting to /dev/null and simply closing the stream

HotTag

Archive