import io from 'socket.io-client';
this.socket = io(global.socketIP, {'force new connection': true});
this.socket.on('connect', () => {
cookie.set('socketIO', this.socket.id);
})
//socketio建立连接收消息
this.socket.on(name,function (data) {
console.log('data:', data)
})
//socketio建立连接发消息
this.socket.emit(name,data)
//断开连接
_removeMessage(data){
if(!data) data= {};
for(let key in data){
if(data[key]){
this.socket.removeAllListeners(data[key]);
}
}
}