Safari中是否可以使用Http Streaming Comet? [英] Is Http Streaming Comet possible in Safari?

查看:107
本文介绍了Safari中是否可以使用Http Streaming Comet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过HTTP Streaming Comet,我的意思是永远的iframe/永远的xhr变体,在从服务器推送数据后不会关闭连接,而不是标准轮询和长轮询关闭并重新发送每个服务器推送事件的新请求。

By HTTP Streaming Comet, I mean the "forever iframe" / "forever xhr" variations that don't close the connection after data has been pushed from the server, as opposed to standard polling and long polling which close and resend a new request for every server push event.

我查看了dojo.io.cometd包,看起来他们只有轮询实现。我还找到了这个例子,但它似乎在webkit中不起作用相当多的修修补补(我让它在其他地方工作)。 来自safari博客的这个公告似乎表明它可以用xhr,但我不能找到任何代码或文档,我也无法使用它。

I looked at the dojo.io.cometd package and it seems they only have polling implementations. I also found this example, but it doesn't seem to work in webkit even after a fair bit of tinkering (I got it to work everywhere else). This announcement from the safari blog seems to suggest that it's possible with xhr, but I couldn't find any code or documentation, nor I could get it to work.

有没有人知道在Webkit浏览器中完成HTTP流媒体彗星的技术,脚本,库或演示( Safari和Chrome)?

Does anyone know of a technique, script, library or demo that accomplishes HTTP streaming comet in Webkit browsers (Safari and Chrome)?

更新

经过多一点修改后,我发现有两个需要做的事情才能通过XHR在Safari中使用http流:

After a bit more tinkering, I found that there are two things that need to be done in order to get http streaming working in Safari via XHR:


  • 响应需要有一个Content-Type: multipart / x-mixed-replace

  • 响应需要在浏览器开始一致地显示更新之前发送一些噪音字符。我假设这与填充一些内部缓冲区有关。

更新2

我终于使用iframe技术在所有浏览器中工作了。解决方案的警告是,只有基于WebKit的浏览器才能接收multipart / x-mixed-replace标头。

I finally got it to work in all browsers using an iframe technique. The caveat to the solution is that only WebKit-based browsers should receive the multipart/x-mixed-replace header.

推荐答案

根据到维基百科,HTTP流媒体彗星应该可以在每个浏览器中使用。 页面布局与框架不是,Ajax:权威指南。 O'Reilly Media,第320页.ISBN 0596528388,是引用此信息的参考文献,因此本书可能会提供有关如何执行此操作的建议。

According to Wikipedia, HTTP Streaming comet is supposed to be possible in every browser. "Page Layout with Frames that Aren't", Ajax: The Definitive Guide. O'Reilly Media, pp. 320. ISBN 0596528388, is the reference that is quoted for this information, so maybe this book has a suggestion on how to do this.

另外 http://meteorserver.org/ 有一个我刚刚确认在Chrome中运行的客户端库的演示+一个将数据推送到客户端的服务器。

Also http://meteorserver.org/ has a demo which I just confirmed works in Chrome, of a client side library + a server which pushes data to the client.

这篇关于Safari中是否可以使用Http Streaming Comet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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