let webSocketTask = null;
webSocketCon() {
let that = this;
that.webSocketTask = wx.connectSocket({
url: 'wss://socket.xxxxx.com',
header: {
'content-type': 'application/json'
},
success: res => {
},
fail: fail => {
},
});
// 打开连接
that.webSocketTask.onOpen(res => {
});
// 接收
that.webSocketTask.onMessage(res => {
});
// 关闭
that.webSocketTask.onClose(err => {
})
// 错误
that.webSocketTask.onError(err => {
});
},