提交 8723ceaf 编写于 作者: Q qiang

fix: 解决部分情况SocketTask.send回调不正确的问题 fixed #744

上级 816ca86b
......@@ -68,6 +68,9 @@ class SocketTask {
const data = options.data
const ws = this._webSocket
try {
if (ws.readyState !== ws.OPEN) {
throw new Error('SocketTask.readyState is not OPEN')
}
ws.send(data)
this._callback(options, 'sendSocketMessage:ok')
} catch (error) {
......@@ -118,11 +121,11 @@ class SocketTask {
}
}
}
eventNames.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1)
SocketTask.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback)
}
eventNames.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1)
SocketTask.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback)
}
})
/**
* 创建一个 WebSocket 连接
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册