网站:
http://html5demos.com/web-socket
客户端源码:
https://github.com/remy/html5demos/blob/master/demos/web-socket.html
检测是否支持websocket
if (window.WebSocket === undefined) {;;
}
开启websocket
conn = {}
{
//新建一个连接
{;;};{);{;{;}};{;;};
}
发送信息:
{
conn.send(JSON.stringify(chat.value)); }
服务端代码解析 省略了,懒得解析,写的非常一般,还不如用java实现算了:
http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76
web socket 最新76协议。