Skip to content

Commit

Permalink
Use the API to determine if the Taobao platform supports websocket mu…
Browse files Browse the repository at this point in the history
…ltiple instances. (#17336)

* Use the API to determine if the Taobao platform supports websocket multiple instances.
  • Loading branch information
bofeng-song authored Jul 9, 2024
1 parent 7b563e6 commit ea0018b
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,10 @@ export cancelAnimationFrame from './cancelAnimationFrame'
export * from './WindowProperties'


const compareVersions = (curVersion, supportedVersion) => {
const curVersionNum = curVersion.split('.').map(Number);
const supportedVersionNum = supportedVersion.split('.').map(Number);

for (let i = 0; i < Math.max(curVersionNum.length, supportedVersionNum.length); i++) {
const curVersionPart = curVersionNum[i] || 0;
const supportedVersionPart = supportedVersionNum[i] || 0;
if (curVersionPart > supportedVersionPart) return 1;
if (curVersionPart < supportedVersionPart) return -1;
}
return 0;
}

import MultiWebSocket from './MultiWebSocket'
import WebSocket from './WebSocket'
const systemInfo = my.getSystemInfoSync();
if (compareVersions(systemInfo.version, '10.35.30') >= 0) {
if (typeof my !== 'undefined' && my && my.canIUse && my.canIUse('connectSocket.object.multiple')) {
$global.WebSocket = MultiWebSocket;
} else {
$global.WebSocket = WebSocket;
Expand Down

0 comments on commit ea0018b

Please sign in to comment.