发送消息什么的都没问题
贴上我得代码
这是uniapp 的
var _this = this;
this.socketTask = socket.connectSocket({
url:'wss://im.xxx.com/websocket',
success: ()=> {
console.log('链接websocket成功')
},
fail:()=>{
console.log('websocket 链接失败');
}
});
this.socketTask.onOpen(function (res) {
_this.socketOpen = true;
for (var i = 0; i < _this.socketMsgQueue.length; i++) {
_this.send_msg(_this.socketMsgQueue[i]);
}
_this.socketMsgQueue = [];
console.log('WebSocket连接已打开!');
_this.php_connect();
// _this.rev_msg();
_this.socketTask.onMessage(function (res) {
console.log('收到服务器内容:' + res.data);
// _this.get_chat_list();
});
console.log(123);
});
_this.socketTask.onError(function (res) {
// _this.socketOpen = false;
console.log(res)
console.log('WebSocket连接打开失败,请检查!');
});
_this.socketTask.onClose(function (res) {
_this.socketOpen = false;
console.log('WebSocket 已关闭!');
});
uni.onSocketMessage(function (res) {
console.log('收到服务器内容:' + res.data);
});
lovnie
请问解决了吗
2021-03-18 18:47