bower install websocket
npm install websocketjs
ws.connect(url, callback, close, error)
ws.connect('ws://127.0.0.1:8080',function(handlers,evn){
//连接成功!
},function(handlers,evn){
//关闭触发!
if(handlers.closeType === "kick"){
console.log('这个是踢下线!的关闭!')
}
},function(handlers,evn){
//连接失败!
})
//ws.message(callback)
ws.message(function(evn,handlers){
console.log(evn.data,handlers)
})
//ws.send()
ws.send('{}') //=>handlers
//ws.disconnect(type,callback) 关闭类型
ws.disconnect("kick",function(data){
})
//ws.isConnect() //=> bool
ws.isConnect() //=> true | false