Google Wave中实时,实时打字的工作原理如何?

时间:2022-10-14 03:53:27

I'm sure Wave doesn't poll the server every millisecond to find out if the other user has typed something... so how can I see what the other person is typing as they type? And without hogging the bandwidth.

我确信Wave不会每毫秒轮询一次服务器,以确定其他用户是否输入了某些东西......那么我怎样才能看到对方输入的内容?而且不会占用带宽。

9 个解决方案

#1


Persistent HTTP, Comet

持久性HTTP,Comet

Keep your HTTP connection alive and send characters as they are typed

保持HTTP连接活动并在键入时发送字符

*Edit in 2014: also, take a look at WebSocket and HTTP/1.1 Upgrade header. Browsers started implementing this around 2010, so I'm adding this to original answer.

* 2014年编辑:另外,看看WebSocket和HTTP / 1.1升级标题。浏览器在2010年左右开始实现这一点,所以我将其添加到原始答案中。

#2


They probably use Web Sockets, aka server-sent events: http://www.w3.org/TR/websockets The underlying protocol can be found (as a draft) at the IETF.

他们可能使用Web套接字,也就是服务器发送的事件:http://www.w3.org/TR/websockets可以在IETF找到基础协议(作为草案)。

Update: it doesn't seem WebSockets has any implementation yet; and a video from Google I/O (go to 11:00) talks about a long lived HTTP GET request.

更新:似乎WebSockets还没有任何实现;来自Google I / O的视频(转到11:00)讨论了长期存在的HTTP GET请求。

#3


Server Push in GWT

GWT中的服务器推送

Server push is the Wait, Respond, Close, Re-Open paradigm:

服务器推送是等待,响应,关闭,重新打开范例:

  • Wait: When the GWT code makes a call to your server for some data that you don't have yet, freeze (wait)

    等待:当GWT代码向您的服务器调用您尚未拥有的某些数据时,请冻结(等待)

  • Respond: Once the requested data is
    available, respond with it

    回复:一旦请求的数据可用,请回复

  • Close: Then, close the connection.

    关闭:然后,关闭连接。

  • Re-Open: Once your GWT code receives the response, immediately open up a new connection to query for the next event.

    重新打开:一旦您的GWT代码收到响应,立即打开一个新连接以查询下一个事件。

#4


See Video Google Wave: Powered by GWT around at minute 55 (near the end)

观看视频Google Wave:由GWT提供支持,在第55分钟(接近结束)

Q: How you implement the persistent Connections, the long living http connections

问:如何实现持久连接,长生活http连接

A: Future Plan: HTML5 Web Sockets. Longer term. That's what we use at the moment.

答:未来计划:HTML5 Web套接字。更长远。这就是我们目前使用的。

Q: Is there a platform or library for this we can download and play with?

问:我们可以下载和玩这个平台或库吗?

A: Not sure. Don't think so

答:不确定。不要这么认为

P.S.: That's what he said. To me it did not make much sense ("future plans" vs "using at the moment"). Any native english speaker might want to verify if I transcribed it correctly?

P.S。:这就是他所说的。对我而言,它没有多大意义(“未来计划”与“目前使用”)。任何母语为英语的人都可能想验证我是否正确转录了它?

#5


Pure speculation but could it be using the Server Side DOM events from the HTML 5 spec?

纯粹的推测,但它可能是使用HTML 5规范中的服务器端DOM事件?

#6


the entire reason for WebSockets is to have the browser keep a bi-directional socket open to a server so that real time communications can be used. When someone types on the other end, in a wave client, it triggers an event that is sent to the server and the server in turn looks to see who should also receive the event and pass them the event, in this case the typed letter.

WebSockets的全部原因是让浏览器保持对服务器开放的双向套接字,以便可以使用实时通信。当某人在另一端键入时,在wave客户端中,它会触发发送到服务器的事件,而服务器依次查看谁还应该接收事件并将事件传递给他们,在这种情况下是键入的字母。

WebSocket and Comet are different.

WebSocket和Comet是不同的。

Granville

#7


Probably comet for now websocket in the future. Because it works in Firefox 3.5 and from what I've read the websocket is only available in the nightly builds of FF... I could be wrong though... as it appears to not work in IE at all.

现在可能是将来的websocket彗星。因为它可以在Firefox 3.5中运行,而且从我读过的内容中,websocket仅在FF的夜间版本中可用...我可能错了但是...因为它似乎根本不适用于IE。

#8


I spent some time reverse-engineering the Google Wave client code (shameless plug for http://antimatter15.com/misc/read/ which is a read-only public client for google wave for all public waves without need of robots or gadgets which was a lot more useful a month ago when Google didn't launch the upgrades).

我花了一些时间对Google Wave客户端代码进行逆向工程(无耻插件http://antimatter15.com/misc/read/,这是一个只读公共客户端,用于所有公共波浪的谷歌波,无需机器人或小工具一个月前谷歌没有启动升级时更有用了)。

Anyway, Google uses the GWT framework with certain aspects of the Google Closure library (which is actually open source and documented) and they use the goog.net.BrowserChannel library, which from the comments is also used for chat functionality within gmail.

无论如何,谷歌使用GWT框架与谷歌闭包库的某些方面(实际上是开源和文档),他们使用goog.net.BrowserChannel库,其中的评论也用于gmail内的聊天功能。

http://closure-library.googlecode.com/svn/docs/closure_goog_net_browserchannel.js.html

#9


I would assume that they use ajax requests. Do an XMLHttpRequest, which is asynchronous, and when the server has something to send your browser the javascript callback that was registered gets the data and does whatever with it. So basically the browser requests the next event, handles it, repeats indefinitely.

我会假设他们使用ajax请求。做一个异步的XMLHttpRequest,并且当服务器有东西发送你的浏览器时,注册的javascript回调获取数据并做任何事情。所以基本上浏览器会请求下一个事件,处理它,无限重复。

#1


Persistent HTTP, Comet

持久性HTTP,Comet

Keep your HTTP connection alive and send characters as they are typed

保持HTTP连接活动并在键入时发送字符

*Edit in 2014: also, take a look at WebSocket and HTTP/1.1 Upgrade header. Browsers started implementing this around 2010, so I'm adding this to original answer.

* 2014年编辑:另外,看看WebSocket和HTTP / 1.1升级标题。浏览器在2010年左右开始实现这一点,所以我将其添加到原始答案中。

#2


They probably use Web Sockets, aka server-sent events: http://www.w3.org/TR/websockets The underlying protocol can be found (as a draft) at the IETF.

他们可能使用Web套接字,也就是服务器发送的事件:http://www.w3.org/TR/websockets可以在IETF找到基础协议(作为草案)。

Update: it doesn't seem WebSockets has any implementation yet; and a video from Google I/O (go to 11:00) talks about a long lived HTTP GET request.

更新:似乎WebSockets还没有任何实现;来自Google I / O的视频(转到11:00)讨论了长期存在的HTTP GET请求。

#3


Server Push in GWT

GWT中的服务器推送

Server push is the Wait, Respond, Close, Re-Open paradigm:

服务器推送是等待,响应,关闭,重新打开范例:

  • Wait: When the GWT code makes a call to your server for some data that you don't have yet, freeze (wait)

    等待:当GWT代码向您的服务器调用您尚未拥有的某些数据时,请冻结(等待)

  • Respond: Once the requested data is
    available, respond with it

    回复:一旦请求的数据可用,请回复

  • Close: Then, close the connection.

    关闭:然后,关闭连接。

  • Re-Open: Once your GWT code receives the response, immediately open up a new connection to query for the next event.

    重新打开:一旦您的GWT代码收到响应,立即打开一个新连接以查询下一个事件。

#4


See Video Google Wave: Powered by GWT around at minute 55 (near the end)

观看视频Google Wave:由GWT提供支持,在第55分钟(接近结束)

Q: How you implement the persistent Connections, the long living http connections

问:如何实现持久连接,长生活http连接

A: Future Plan: HTML5 Web Sockets. Longer term. That's what we use at the moment.

答:未来计划:HTML5 Web套接字。更长远。这就是我们目前使用的。

Q: Is there a platform or library for this we can download and play with?

问:我们可以下载和玩这个平台或库吗?

A: Not sure. Don't think so

答:不确定。不要这么认为

P.S.: That's what he said. To me it did not make much sense ("future plans" vs "using at the moment"). Any native english speaker might want to verify if I transcribed it correctly?

P.S。:这就是他所说的。对我而言,它没有多大意义(“未来计划”与“目前使用”)。任何母语为英语的人都可能想验证我是否正确转录了它?

#5


Pure speculation but could it be using the Server Side DOM events from the HTML 5 spec?

纯粹的推测,但它可能是使用HTML 5规范中的服务器端DOM事件?

#6


the entire reason for WebSockets is to have the browser keep a bi-directional socket open to a server so that real time communications can be used. When someone types on the other end, in a wave client, it triggers an event that is sent to the server and the server in turn looks to see who should also receive the event and pass them the event, in this case the typed letter.

WebSockets的全部原因是让浏览器保持对服务器开放的双向套接字,以便可以使用实时通信。当某人在另一端键入时,在wave客户端中,它会触发发送到服务器的事件,而服务器依次查看谁还应该接收事件并将事件传递给他们,在这种情况下是键入的字母。

WebSocket and Comet are different.

WebSocket和Comet是不同的。

Granville

#7


Probably comet for now websocket in the future. Because it works in Firefox 3.5 and from what I've read the websocket is only available in the nightly builds of FF... I could be wrong though... as it appears to not work in IE at all.

现在可能是将来的websocket彗星。因为它可以在Firefox 3.5中运行,而且从我读过的内容中,websocket仅在FF的夜间版本中可用...我可能错了但是...因为它似乎根本不适用于IE。

#8


I spent some time reverse-engineering the Google Wave client code (shameless plug for http://antimatter15.com/misc/read/ which is a read-only public client for google wave for all public waves without need of robots or gadgets which was a lot more useful a month ago when Google didn't launch the upgrades).

我花了一些时间对Google Wave客户端代码进行逆向工程(无耻插件http://antimatter15.com/misc/read/,这是一个只读公共客户端,用于所有公共波浪的谷歌波,无需机器人或小工具一个月前谷歌没有启动升级时更有用了)。

Anyway, Google uses the GWT framework with certain aspects of the Google Closure library (which is actually open source and documented) and they use the goog.net.BrowserChannel library, which from the comments is also used for chat functionality within gmail.

无论如何,谷歌使用GWT框架与谷歌闭包库的某些方面(实际上是开源和文档),他们使用goog.net.BrowserChannel库,其中的评论也用于gmail内的聊天功能。

http://closure-library.googlecode.com/svn/docs/closure_goog_net_browserchannel.js.html

#9


I would assume that they use ajax requests. Do an XMLHttpRequest, which is asynchronous, and when the server has something to send your browser the javascript callback that was registered gets the data and does whatever with it. So basically the browser requests the next event, handles it, repeats indefinitely.

我会假设他们使用ajax请求。做一个异步的XMLHttpRequest,并且当服务器有东西发送你的浏览器时,注册的javascript回调获取数据并做任何事情。所以基本上浏览器会请求下一个事件,处理它,无限重复。