Push and pull technologies using Ajax or Socket

I have a website that should send real-time notifications to online clients just like Facebook, after you searched more, I found a lot of documentation on push and pull technology. I found from this documentation how to implement them using Ajax or Sockets. I need to know what is best used in my case and how it is encoded using javascript or jquery and php.

+3
source share
3 answers

I can’t tell you what is best used in your case, not knowing your case in detail.

In most cases, it is enough for clients to check with the server every one or two seconds, asking if something new has happened. I prefer this over sockets most of the time because it runs on every web server without any configuration changes and in any browser that supports AJAX, even the old ones.

If you have few clients (because each client requires an open socket on the server) and you want real-time, you can use websockets. There are several PHP implementations, for example: http://code.google.com/p/phpwebsocket/

+2
source

If you can guarantee that only one browser will be open for a user registered in the journal, you can easily apply this long-term survey method.

Policy for calling Ajax:

  • 2 .
  • 2 .
  • 12 , . .

:

  • . , ; (, , , , )

  • sleep() 1 ; ( , ), , ; ; 1 ; , 10 ,

( ), , 95% 4% .

, . .

+2

Just use the long polling method with jQuery.

Sockets are not yet supported everywhere, and you will need to open a listening socket on the server for this to work.

0
source

All Articles