找回密码
 FreeOZ用户注册
查看: 1958|回复: 0
打印 上一主题 下一主题

[新技术交流] Google Chrome开始支持Web Socket标准

[复制链接]
跳转到指定楼层
1#
发表于 15-12-2009 10:58:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
Google Chrome开始支持Web Socket标准

Slashdot/Solidot报道: http://it.solidot.org/article.pl?sid=09/12/11/0315211&;from=rss

Web Sockets Now Available In Google Chrome
例子:

  1. if ("WebSocket" in window) {
  2. var ws = new WebSocket("ws://example.com/service");
  3. ws.onopen = function() {
  4. // Web Socket is connected. You can send data by send() method.
  5. ws.send("message to send"); ....
  6. };
  7. ws.onmessage = function (evt) { var received_msg = evt.data; ... };
  8. ws.onclose = function() { // websocket is closed. };
  9. } else {
  10. // the browser doesn't support WebSocket.
  11. }
复制代码



IETF WebSocket协议草案

W3C WebSocket API标准

W3C WebSocket标准中的WebSocket 接口

  1. [Constructor(in DOMString url, in optional DOMString protocol)]
  2. interface WebSocket {
  3. readonly attribute DOMString URL;

  4. // ready state
  5. const unsigned short CONNECTING = 0;
  6. const unsigned short OPEN = 1;
  7. const unsigned short CLOSED = 2;
  8. readonly attribute unsigned short readyState;
  9. readonly attribute unsigned long bufferedAmount;

  10. // networking
  11. attribute Function onopen;
  12. attribute Function onmessage;
  13. attribute Function onclose;
  14. boolean send(in DOMString data);
  15. void close();
  16. };
  17. WebSocket implements EventTarget;
复制代码



回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+11, 2-11-2024 04:36 , Processed in 0.019200 second(s), 16 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表