如何用 PHP 实现真正的快速网络聊天? [英] How to implement a real fast web chat with PHP?

查看:27
本文介绍了如何用 PHP 实现真正的快速网络聊天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用 PHP 实现真正的快速网络聊天?

How to implement a real fast web chat with PHP?

有没有人想过为什么 Facebook 聊天这么快?即使在没有 WebSocket 的 IE 中.

Has anybody ever wonder why Facebook chat is just so really really fast? even in IE without WebSocket.

不是唯一的方法是在JS中设置间隔来检查新消息吗?但我觉得(Facebook 聊天框)就像是即时反应.

Isn't the only way is to setInterval in JS to check for new messages? But I feel it (Facebook chat box) like having instant reaction.

如何用 PHP 实现这么棒的东西?

How to implement such great thing with PHP?

推荐答案

您所描述的即时聊天通常是通过一种称为长轮询"的东西来实现的,或者,如果我们谈论的是 AJAX,则是彗星"(维基百科 谈论).轮询往往会给 Apache 服务器带来压力,但有一些专门的服务器可以处理它,例如 APE.我不确定,但我认为你可以用 NodeJSNGINX 很好地处理了压力.

The instantaneous chat you're describing is generally acheived by a something called "Long Polling" or, if we're talking about AJAX, "Comet" (Wikipedia talks about it). Polling tends to strain Apache servers, but there are some specialized servers to deal with it like APE. I'm not sure but I think you can do the same with NodeJS and NGINX handles the stress pretty well.

这里是一篇关于如何使用 PHP jQuery 和 AJAX 实现长轮询聊天.

Here's an article here about how to implement a long polling chat with PHP jQuery and AJAX.

祝你好运,希望对你有帮助!

Best of luck, and I hope it helped!

这篇关于如何用 PHP 实现真正的快速网络聊天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆