node.js - How to reflect event that happened on the server, in the browser -


i beginner nodejs. wondering how signify/visualize event happened in server. example event might happen once in every 20sec, , want give signal in browser have happened.

i thinking approach request/poll server every 10msec, doesn't seem efficient.

any better ideas?

there 2 way propagate event happen server front.

  • front polling. every x sec front gonna ask server news.

    front : "did happen?"

    back : "yes ..."

  • websocket communication. front open websocket connection server , wait news. happen on back, server send message front. no polling, no useless messages.

a famous websocket socket.io. what's used create chats example.


schema representation of difference of treatment :

enter image description here


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -