网站:

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协议。

 

相关文章:

  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-09-07
  • 2021-05-24
  • 2021-07-08
  • 2021-08-24
  • 2021-12-26
猜你喜欢
  • 2021-08-21
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2021-11-23
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案