开发者

how does comet work with php?

when i use comet iframe i just send script tags from backend php file to front end and javascri开发者_JS百科pt is displaying it.

can someone explain briefly where a comet server comes up in the picture and how the communication will be between frontend (javascript), backend (php) and the comet server.

cause i read that if you are going to let a lot of users use your comet application it's better to have a comet server. but i dont quite understand the coupling between these parts.


use this link:

http://www.zeitoun.net/articles/comet_and_php/start

That is the best tutorial i could found, and takes 1 min to try;

in short:

how does comet work with php?

( image from that tutorial )

index, can be html or php, creates a request, which php doesnt answer until there is data to send back, with chat, when someone sends you a message.

If you have many users chatting, i recommend using a java chat app

otherwise your server will load up with running php engines ( each unanswered request keeps a php engine alive, which is server capacity ).

http://streamhub.blogspot.com/2009/07/tutorial-building-comet-chat.html

this should help you out with that, but you do need java hosting :)

have fun

edit:

just read the other server part; sending requests to your own server can get messed because the timeout function may not work well, so the server crashes, an independant server timeouts the connection after a certain amount of time, no matter what.


I have a very simple example here that can get you started with comet. It covers compiling Nginx with the NHPM module and includes code for simple publisher/subscriber roles in jQuery, PHP, and Bash.

http://blog.jamieisaacs.com/2010/08/27/comet-with-nginx-and-jquery/

A working example (simple chat) can be found here:
http://cheetah.jamieisaacs.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜