comet 如何与 php 一起工作?

发布于 2024-08-17 17:08:38 字数 217 浏览 4 评论 0 原文

当我使用 comet iframe 时,我只是将脚本标签从后端 php 文件发送到前端,并且 javascript 正在显示它。

有人可以简要解释一下彗星服务器在图片中出现的位置以及前端(javascript)、后端(php)和彗星服务器之间的通信方式。

因为我读到,如果您打算让很多用户使用您的 comet 应用程序,那么最好有一个 comet 服务器。但我不太明白这些部分之间的耦合。

when i use comet iframe i just send script tags from backend php file to front end and javascript 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

成熟稳重的好男人 2024-08-24 17:08:39

使用此链接:

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

这是我能找到的最好的教程,需要 1 分钟来尝试;

简而言之:

“alt

(该教程中的图片)

索引,可以是 html 或 php,创建一个请求,当有人向您发送消息时,只有通过聊天发送回数据后,php 才会回复该请求。

如果您有很多用户聊天,我建议使用 java 聊天应用程序,

否则您的服务器将加载正在运行的 php 引擎(每个未应答的请求都会使 php 引擎保持活动状态,这就是服务器容量)。

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

这应该可以帮助你解决这个问题,但是你确实需要java托管:)

玩得开心

编辑:

只需阅读其他服务器部分;向自己的服务器发送请求可能会变得混乱,因为超时功能可能无法正常工作,因此服务器崩溃,独立的服务器在一定时间后使连接超时,无论如何。

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:

alt text

( 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.

筑梦 2024-08-24 17:08:39

我这里有一个非常简单的例子,可以帮助您开始使用 comet。它涵盖了使用 NHPM 模块编译 Nginx,并包含 jQuery、PHP 和 Bash 中简单发布者/订阅者角色的代码。

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

可以在此处找到工作示例(简单的聊天):
http://cheetah.jamieisaacs.com/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文