这篇文章需要技术复核。如何帮忙。
这篇文章需要文法复核。如何帮忙。
这篇翻译不完整。请帮忙从英语翻译这篇文章。
WebSockets 是一种 先进的技术, 它使得在用户的浏览器和服务器之间建立一个 双向通信的会话成为可能, 你可以向服务器发送消息, 然后接收事件驱动的响应, 而无需轮询服务器得到回复.
接口
WebSocket
- 主要接口, 用于连接到 WebSocket 服务器, 并在打开的连接上收发数据.
CloseEvent
- 当连接关闭时 WebSocket 对象发出的事件.
MessageEvent
- 当收到服务器消息时 WebSocket 对象发出的事件.
工具
- Socket.IO: 一个强大的跨平台的 Node.js WebSocket API.
- WebSocket-Node: 一个 Node.js WebSocket 服务器 API 实现.
- Total.js: Node.js Web 应用框架 (示例: WebSocket chat)
- Faye: 可供 Node.js 客户端和服务器使用的 WebSocket (双向连接) 和 EventSource (单向连接) 实现.
相关话题
另见
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Version -76 support | 6 | 4.0 (2.0) | 未实现 | 11.00 (disabled) | 5.0.1 |
Protocol version 7 support | 未实现 | 6.0 (6.0) Moz |
未实现 | 未实现 | 未实现 |
Protocol version 10 support | 14 | 7.0 (7.0) Moz |
HTML5 Labs | ? | ? |
Standard - RFC 6455 Support | 16 | 11.0 (11.0) | 10 | 12.10 | 6.0 |
Usable in Workers | (Yes) | 37.0 (37.0) | ? | ? | ? |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Version -76 support | ? | ? | ? | ? | ? |
Protocol version 7 support | ? | ? | ? | ? | ? |
Protocol version 8 support (IETF draft 10) | ? | 7.0 (7.0) | ? | ? | ? |
Standard - RFC 6455 Support | 4.4 | 11.0 (11.0) | ? | 12.10 | 6.0 |
Usable in Workers | (Yes) | 37.0 (37.0) | ? | ? | ? |
Gecko 注意事项
为了符合 WebSocket 规范, Firefox 对 WebSockets 的支持是在持续进行中的. Firefox 6 实现了版本 7 的底层协议, 而 Firefox 7 则实现了版本 8 (在 IETF 草案 10 中提出). Firefox mobile 版本则在 7.0 开始支持 WebSocket.
Gecko 6.0
Prior to Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3), there was, incorrectly, a WebSocket
object that some sites were thinking implied that WebSocket
services were not prefixed; this object has been renamed to MozWebSocket
.
Gecko 7.0
Starting in Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4), the network.websocket.max-connections
preference is used to determine the maximum number of WebSocket connections that can be open at a time. The default value is 200.
Gecko 8.0
Starting in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5), the deflate-stream extension to the WebSocket protocol has been disabled, since it's been deprecated from the specification drafts. This resolves incompatibilities with some sites.
Gecko 11.0
Prior to Gecko 11.0, both incoming and outgoing messages were limited to 16 MB in size. They may now be up to 2 GB in size. Note, however, that memory limitations (especially on mobile devices) make that a theoretical maximum, not a practical one. In reality, transfers of that size will fail on devices that don't have enough memory.
Additionally, ArrayBuffer send and receive support for binary data has been implemented.
Starting in Gecko 11.0, the WebSocket API is no longer prefixed.