Skip to content

Commit

Permalink
fix taobao mini game MultiWebSocket some issues (#17349)
Browse files Browse the repository at this point in the history
* fix taobao mini game MultiWebSocket refrence issue

* fix taobao mini game MultiWebSocket onMessage data format change issue
  • Loading branch information
vivi32767 authored Jul 17, 2024
1 parent ce86b12 commit c1f29fc
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class MultiWebSocket {
}

this.url = url
this.readyState = WebSocket.CONNECTING
this.readyState = MultiWebSocket.CONNECTING

const socketTask = my.connectSocket({
url,
Expand All @@ -34,23 +34,23 @@ export default class MultiWebSocket {
this._socketTask = socketTask;

socketTask.onClose((res) => {
this.readyState = WebSocket.CLOSED
this.readyState = MultiWebSocket.CLOSED
if (typeof this.onclose === 'function') {
this.onclose(res)
}
})

socketTask.onMessage((res) => {
if (typeof this.onmessage === 'function') {
if (res && res.data && res.isBuffer) {
res.data = _utils.base64ToArrayBuffer(res.data)
if (res && res.data && res.data.data && res.data.isBuffer) {
res.data = _utils.base64ToArrayBuffer(res.data.data)
}
this.onmessage(res)
}
})

socketTask.onOpen((res) => {
this.readyState = WebSocket.OPEN
this.readyState = MultiWebSocket.OPEN
if (typeof this.onopen === 'function') {
this.onopen(res)
}
Expand All @@ -64,7 +64,7 @@ export default class MultiWebSocket {
}

close(code, reason) {
this.readyState = WebSocket.CLOSING
this.readyState = MultiWebSocket.CLOSING

this._socketTask.close({
code,
Expand Down

0 comments on commit c1f29fc

Please sign in to comment.