请教一下,wx.connectSocket还没有成功返回SocketTask,紧接着就调用socket.onOpen()、socket.onMessage(),
此时会报socket undefined的错误。这个问题应该怎么解决呢?
代码如下
var socket = wx.connectSocket({
url: 'ws://127.0.0.1:8080/test',
success: function (resConnect) {
console.log("resConnect: ", resConnect);
},
fail: function (resConnectError) {
console.log("resConnectError: ", resConnectError);
}
});
socket.onOpen(function (resOpen) {
console.log("连接已打开:", resOpen)
})
socket.onMessage(function (resMessage) {
console.log("socket接收到消息:", resMessage)
})
有没有官方人员解答一下呀
在成功回调里面调用
url: ‘ws://127.0.0.1:8080/test‘,
success: function (resConnect) {
},
fail: function (resConnectError) {
}
});
成功回调里面拿不到返回的socket呀