替代 WebSocket [英] Alternative to WebSockets

查看:53
本文介绍了替代 WebSocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WebSockets 的前景感到非常兴奋.由于我过去曾构建过一些基于桌面套接字的游戏和网络游戏,因此我很想结合这两种方法来构建多人基于网络的游戏,而无需长轮询 hack.

自从有消息称 Firefox 和 Opera 由于安全问题禁用了 websockets (见这里),WebSockets 在不久的将来会终结吗?

如果 WebSockets 确实已死(或在可预见的未来被推迟),除了长轮询之外还有其他选择吗?

解决方案

WebSockets 生机勃勃.只有 firefox 4 beta 禁用了原生 WebSockets 支持,Chrome 和 Safari 没有.Opera 宣布,在问题得到解决之前,他们不会随它一起发布版本,但无论如何从未发布过 alpha/beta 版本.

此外,很多(也许是大多数)使用 WebSockets 的项目都使用 web-socket-js (Flash) 回退.对于这些项目,当在没有 WebSockets 或禁用它的浏览器上运行时,将使用 web-socket-js.它会比原生效率低,但仍然比长轮询低得多.

但同样重要的是要记住,WebSockets 比 HTML5 的大多数其他部分要年轻得多(部分原因是它在几个月前被拆分了)并且它仍处于草案阶段.

此外,HyBi 工作组(负责起草 WebSockets 协议)刚刚发布了一个 更新了标准草案 04,解决了浏览器供应商的安全问题(特别注意,这些问题不是因为 WebSockets 中的漏洞,而是因为 WebSockets 可能被用来利用 HTTP 中介中的漏洞).>

关于 WebSockets 的讨论 仍然非常活跃在 HyBi 上.我预计在进入下一轮浏览器版本之前,可能会有另一个草案进一步改进.浏览器供应商都希望解决 WebSockets 解决的问题(来自浏览器的低延迟、低开销的网络通信),因此向 WebSockets 的发展正在迅速发生.

当前的凹凸只是一个凹凸.但是无论原生实现需要多长时间才能完成,您仍然可以使用 web-socket-js 在每个浏览器上使用 WebSockets.

更新:

解决安全问题(除其他事项外)的新 HyBi 协议已完成,预计将于本月(2011 年 11 月)正式发布.HyBi-17 是该规范的最新版本.>

在 IE10 开发者预览版中,包括 WebSockets、Opera 和 Android 浏览器是唯一没有提供默认启用的 WebSockets 实现的浏览器(可以手动启用 Opera 的实现).我希望这会很快改变,同时 web-socket-js 已更新为HyBi 协议系列,对于没有默认支持的浏览器来说仍然是一个很好的 polyfill/shim.

I have been quite excited by the prospect of WebSockets. As I have built a few Desktop socket based games, and Web games in the past, I was keen to combine the two approaches to building multiplayer web-based games without a long-polling hack.

Since the news that Firefox and Opera have disabled websockets due to security issues (see here), is that the end of WebSockets for the near future?

If WebSockets are indeed dead (or postponed for the foreseeable future), are there any alternatives other than Long Polling?

解决方案

WebSockets are alive and kicking. Only firefox 4 beta has disabled native WebSockets support, Chrome and Safari have not. Opera announced that they won't ship a release with it until the issues were addressed but never shipped a alpha/beta release with it turned on anyways.

In addition, a lot (perhaps most) of the projects that use WebSockets use the web-socket-js (Flash) fall-back. For those projects, when running on browsers with no WebSockets or with it disabled, web-socket-js will be used. It will be less efficient than native, but still much lower latency than long-polling.

But it's also important to remember that WebSockets is much younger than most of the other parts of HTML5 (part of the reason it was split off several months ago) and it is still very much in draft stage.

Also, the HyBi working group (responsible for drafting the WebSockets protocol) has just released a updated draft standard 04 that addresses the browser vendor security concerns (note in particular that the concerns are not because of a vulnerability in WebSockets but that WebSockets may be used to exploit vulnerabilities in HTTP intermediaries).

The discussion about WebSockets is still very active on HyBi. I expect there may be another draft with further improvements before it makes it into the next round of browser releases. The browser vendors all desire to solve the problem that WebSockets addresses (low-latency, low-overhead network communication from the browser) so the movement towards WebSockets is happening fast.

The current bump is just a bump. But regardless of how long the native implements take to finalize, you can still use WebSockets on every browser using web-socket-js.

Update:

The new HyBi protocol that addresses the security concern (among other things) is complete and is expected to be officially published this month (Nov 2011). HyBi-17 is the latest version of the spec.

With IE10 developer preview including WebSockets, Opera and Android's browser the only browsers that are not shipping a WebSockets implementation that is on by default (Opera's implementation can be manually enabled). I expect that will change soon and in the meantime web-socket-js has been updated to the HyBi protocol series and is still a good polyfill/shim for browsers without default support.

这篇关于替代 WebSocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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