Google Chrome开始支持Web Socket标准
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
例子:
if ("WebSocket" in window) {
var ws = new WebSocket("ws://example.com/service");
ws.onopen = function() {
// Web Socket is connected. You can send data by send() method.
ws.send("message to send"); ....
};
ws.onmessage = function (evt) { var received_msg = evt.data; ... };
ws.onclose = function() { // websocket is closed. };
} else {
// the browser doesn't support WebSocket.
}
IETF WebSocket协议草案
W3C WebSocket API标准
W3C WebSocket标准中的WebSocket 接口
interface WebSocket {
readonly attribute DOMString URL;
// ready state
const unsigned short CONNECTING = 0;
const unsigned short OPEN = 1;
const unsigned short CLOSED = 2;
readonly attribute unsigned short readyState;
readonly attribute unsigned long bufferedAmount;
// networking
attribute Function onopen;
attribute Function onmessage;
attribute Function onclose;
boolean send(in DOMString data);
void close();
};
WebSocket implements EventTarget;
页:
[1]