Skip to content Skip to sidebar Skip to footer

Listen To Server Changes

a server has certain variables with values which change on a regular basis. These changes don't emit events or anything. My JavaScript Application receives the values through HTTP-

Solution 1:

In a node.js app (server), you could :

  • set up a socket.io connection with your client
  • create an event EventEmitter A
  • subscribe to your event emitter
  • do a setInterval to check your variables
  • when one of your variables has changed -> A.emit('variable-name', newValue)
  • You recieve the event from A and send it to your client through socket.io

Post a Comment for "Listen To Server Changes"