Capture message update automatically on the front end

1

I would like to know how the process of capturing post and post updates (backend) is automatically done through the font-end (like the one performed by facebook). Anyone have an idea?

Is this done through threads in js?

    
asked by anonymous 10.10.2014 / 17:06

1 answer

4

There are 3 general lines, namely:

a. a recursive timeout looking for new information. when this information exists, it is displayed. this approach is more common because it is simpler to implement, but it is not recommended because it is not scalable, that is, in an environment with thousands of users thousands of requests will be made * N seconds, most of them unnecessary, increasing bandwidth and infra expenses structure.

b. ajax comet. is a technique that leaves an http connection open so that the application can send information to the browser even after some time (usually http connections last only a few seconds, ajax comet is to circumvent this feature of http). search for ajax comet associated with the language you program in a search engine you will find several tutorials.

c. websocket. is only available in modern browsers. is a new protocol and it allows roundtrip communication with the browser (this is the approach we will all use in the near future, today it has the problem of not working in legacy browsers).

note 1: facebook uses a merge between a and b. basically uses comet but when the activity decreases it closes the connection and changes to a recursive timeout that also dies after a while. after a long time of inactivity it only refreshes when the user interacts with the page.

note 2: each of these paths has several techniques with advantages and disadvantages. take a look here about ajax comet, it gets well clarified:

link

    
10.10.2014 / 17:28