$.extend({
socketWeb:function (opt) {
if("WebSocket" in window){
var setting=$.extend({
url:'',
opens:{},
messages:{},
closes:{},
err:{}
},opt);
var ws=new WebSocket(setting.url);
ws.onopen=setting.opens();
ws.onmessage=setting.messages();
ws.onclose=setting.closes();
ws.οnerrοr=setting.err();
}else{
alert("您的浏览器不支持 WebSocket!");
}
}
});
$.socketWeb({
url:'ws://http://127.0.0.1:1234/',
opens:function (ev) {
} ,
messages:function (ev) {
},
closes:function (ev) {
},
err:function (ev) {
}
});