GMail Chat 如何在没有客户端交互的情况下发出 AJAX 请求?

发布于 2024-07-16 22:07:15 字数 111 浏览 7 评论 0原文

所有 HTTP 响应都需要客户端启动它们,即使是使用 AJAX 做出的响应。 但 GMail 的聊天功能能够接收来自其他用户的消息,即使我只是坐在舒适的电脑椅上观看但不与浏览器交互。 他们是如何做到的呢?

All HTTP responses require the client to initiate them, even those made using AJAX. But GMail's chat feature is able to receive messages from other users, even when I'm just sitting in my comfy computer chair watching but not interacting with the browser. How did they do it?

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

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

发布评论

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

评论(3

暗恋未遂 2024-07-23 22:07:15

该技术被称为“comet”,也被称为“服务器推送”、“反向 ajax”等。

它是将数据从服务器推送到浏览器,保持 http 连接处于活动状态。 在维基百科文章 (英文版)。

另外,这里还有来自 DWR 的 Joe Walker 的相当不错的演示,他在其中进行了演讲关于彗星。

That tech is known as "comet", but also as "server push", "reverse ajax", etc.

It's about pushing data from the server to the browser, keeping an http connection alive. Find more info on it on the wikipedia article (English version).

Also here's a pretty good presentation with Joe Walker from DWR, where he talks about comet.

跨年 2024-07-23 22:07:15

正如您正确指出的那样,HTTP 要求客户端“拉取”数据。 Gmail 仍然可以通过使用计时器触发 HTTP 操作来从服务器“拉取”数据,而不需要用户单击某些内容。 因此,它可能看起来是自动的,但它仍然是客户端发起的。

As you rightfully pointed out, HTTP requires data to be 'pulled' by the client. Gmail can still 'pull' data from the server by using a timer to trigger the HTTP operation instead of requiring the user to click something. So, it may seem to be auto, but it is still client initiated.

余生共白头 2024-07-23 22:07:15

是的,彗星是正确的。 Ryan Dewsbury 的 Google Web Toolkit 应用程序介绍了如何创建基于 Comet 的即时通讯工具应用见第 9 章。

Yep Comets is correct. Google Web Toolkit Applications by Ryan Dewsbury explains how to create a Comets based Instant Messenger application in chapter 9.

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