服务器推送:彗星 vs 猿?

发布于 2024-08-17 06:21:20 字数 137 浏览 4 评论 0原文

我读过一些关于彗星和 APE 的内容。

哪一个更好?我希望用户看到其他用户更新的内容。就像谷歌波一样。

而在comet中,有2个版本:iframe vs 传统的ajax。有什么区别,哪个更好。我不太明白。

谢谢。

I've read a little about comet and also APE.

Which one is better? I want the users to see other users updated content. Like Google Wave.

And in comet, there are 2 versions: iframe vs traditional ajax. what is the difference and which is better. I dont quite understand it.

Thanks.

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

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

发布评论

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

评论(8

黎歌 2024-08-24 06:21:20

Comet 是一组可用于开发实时应用程序的技术。您有两种主要实现:流式传输和长轮询。

在常规 http 请求中,用户将请求发送到服务器,接收数据(html、脚本等)并关闭连接 - 故事结束。
在流式传输中,客户端或服务器永远不会关闭连接,双方共享一个连接。

在长轮询中,您有一个等待响应的循环连接。基本上,浏览器向服务器发送请求,并等待服务器响应(服务器仅在为客户端提供新数据时才响应),然后关闭连接,由浏览器重新打开连接,然后循环重复:) 在这两者中,这是最常用的。

浏览器中的 Comet 通常需要一个针对大量长期 HTTP 连接进行优化的 Web 服务器,以及一个 JavaScript 客户端来与 Comet 服务器进行通信。所以 Ape 是一个可安装的服务器,Comet 是它所基于的范例。
这里有一个 Comet 实现列表:http://cometdaily.com/maturity.html

Comet is a set of techniques useful for developing realtime applications. You have two main implementations: streaming and long polling.

In regular http requests the user sends the request to the server, receives the data (html, scrips, etc) and closes the connection - end of story.
In streaming the connection is never closed by the client or the server, there's a single connection shared by both parties.

In long polling, you have a recurring connection that waits for a response. Basically, the browser sends a request to the server and sits there waiting until the server responds (the server only responds when he has new data for the client), then the connection is closed and it's up to the browser to reopen a connection, and the cycle repeats :) Of the two, this is the most used.

Comet in the browser typically requires a web server optimized for large numbers of long-lived HTTP connections, and a JavaScript client to communicate with the Comet server. So Ape is an installable server and Comet is the paradigm on which it is based.
Here you have a list of comet implementations: http://cometdaily.com/maturity.html

自由范儿 2024-08-24 06:21:20

Comet = 该技术的总称,也称为“反向 ajax”或“长轮询”

APE = Comet 技术的实现。

您可以将 Comet 视为某种汽车品牌,而 APE 则视为型号。

另请参阅:

http://en.wikipedia.org/wiki/Comet_%28programming%29

http://www.ape-project.org/ajax-push。 html

Comet = Umbrella term for the technology also known as "reverse ajax" or "long polling"

APE = An implementation of Comet technology.

You can think of Comet being a certain make of car while APE is the model.

See also:

http://en.wikipedia.org/wiki/Comet_%28programming%29

http://www.ape-project.org/ajax-push.html

仅此而已 2024-08-24 06:21:20

Comet是一项技术,APE是众多实现之一。
iframe 与传统的ajax 相比怎么样?在任何可以使用 HTML5 WebSocket 的地方使用它。

现在,所有现代浏览器都使用 XMLHttpRequest 进行 ajax 请求(客户端到服务器、后端)。但有时 JS 应用程序通过 iframe 发送文件是可以的。并非所有 XMLHttpRequests 的实现都支持多部分数据传输(Chrome 和现代 FF afaik)。
WebSockets 是专门为类似 Comet 的技术创建的(当客户端仅打开一个连接并且 Web 服务器通过打开的流或 WebSocket 将一些数据推送到客户端时),因此如果可以的话请使用它。

顺便说一句,我建议您为您的 Comet 流(或频道)使用独立的网络服务器。

PS我喜欢APE。

Comet is a technology, APE is one of a lot implementations.
What about iframe vs traditional ajax? Use HTML5 WebSockets anywhere you can use it.

At now all modern browsers use XMLHttpRequest for ajax requests (client-to-server, something back and end). But sometimes JS-applications sending files via iframes and its ok. Not all implementations of XMLHttpRequests supports multipart-data transport (Chrome and modern FF afaik).
WebSockets was created especially for Comet-like technologies (when client opening only one connection and web-server pushes some data to client via opened stream or WebSocket) so use it if you can.

BTW I'll recommend you to use independent web-server for your Comet-streams (or channels).

P.S. I like APE.

第七度阳光i 2024-08-24 06:21:20

Etherpad.com 是一款超快速的实时文档共享工具,它使用 Comet 来提供其他编辑者协作的近乎实时的屏幕更新。生产 etherpad (AppJet) 的公司刚刚被 Google 收购,以便在 Google Wave 上运行

查看 http:// etherpad.com/ep/about/faq

http://code.google.com /p/etherpad/(开源 etherpad)查看其实现。

我投票支持 Comet,因为 etherpad 取得了商业上的成功,并且使用 comet 实现了 google wave。

Etherpad.com, the super fast real time document sharing tool used comet to provide near real time screen updates of collaborations from other editors. The company that makes etherpad (AppJet) just got purchased by Google to work on Google Wave

Check out http://etherpad.com/ep/about/faq

and http://code.google.com/p/etherpad/ (open source etherpad) to see their implementation.

I vote for comet because of the commercial success of etherpad and the google wave implementation using comet.

终止放荡 2024-08-24 06:21:20

查看 WebSockets。 Chrome 和更新的 Firefox 已经支持它。当您在其他浏览器上确实需要它时,您可以回退到 Comet。

Have a look at WebSockets. Chrome and newer Firefoxes already support it. You can fall back to comet when you really need it on other browsers.

你列表最软的妹 2024-08-24 06:21:20

APE不就是Comet的一个实现吗?这就是产品页面上所说的。

Isn't APE just an implementation of Comet? That's what is says on the product page.

镜花水月 2024-08-24 06:21:20

我认为您想将基于 IFrame 的技术与基于 Ajax (XMLHttp) 的技术进行比较。

我认为主要的区别在于,在浏览器收到整个响应之前,您无法读取 AJAX 请求的响应内容。这意味着,为了模拟流式传输,您必须执行以下操作:

  1. 向服务器发出请求
  2. 收到响应后,读取响应并发出另一个请求

如果没有任何内容可返回,服务器可以保留该请求然而。

另一方面,基于 IFrame 的解决方案可以返回多个 script 标记来响应单个请求。在(浏览器或服务器)请求超时之前,无需发送另一个请求。

I think you want to compare IFrame based techniques with Ajax (XMLHttp) based techniques.

I think the major difference is that you cannot read the response content of an AJAX request until the whole response is received by the browser. Which means, in order to simulate streaming, you will have to do something like this:

  1. Make a request to the server
  2. On getting a response read the response and make another request

The server can hold on the request if there isn't anything to return yet.

IFrame based solution on the other hand can return multiple script tags in response to a single request. There is no need to send another request until there is a (browser or server) request timeout.

倾城°AllureLove 2024-08-24 06:21:20

APE 是 Comet 的一个实现。它提供非阻塞IO服务器和JS客户端库来实现发布/订阅消息系统。

APE 服务器本身可以使用服务器端 JavaScript 进行编程。服务器端代码(例如 PHP/Ruby/任何内容)可以通过向 APE 服务器发出“命令”来通过 APE 广播数据。

连接的客户端通过侦听“Raws”来接收此数据;它们是从 APE 服务器发送到客户端的事件和数据。

APE is an implementation of Comet. It provides a non-blocking IO server and JS client libraries to implement a publish/subscribe messaging system.

The APE server itself can be programmed using server-side javascript. Server side code such as PHP/Ruby/whatever may broadcast data through APE by issuing 'commands' to the APE server.

Connected clients receive this data by listening for 'Raws' ; which are events and data sent from the APE server to the client.

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