|
@@ -36,10 +36,10 @@ function changIsControl(value) {
|
|
|
|
|
|
function throttle(fn, delay) {
|
|
function throttle(fn, delay) {
|
|
var flag = true;
|
|
var flag = true;
|
|
- errorTime += delay;
|
|
|
|
return () => {
|
|
return () => {
|
|
if (!flag) return;
|
|
if (!flag) return;
|
|
flag = false;
|
|
flag = false;
|
|
|
|
+ errorTime += delay;
|
|
timer = setTimeout(() => {
|
|
timer = setTimeout(() => {
|
|
fn();
|
|
fn();
|
|
flag = true;
|
|
flag = true;
|
|
@@ -47,6 +47,10 @@ function throttle(fn, delay) {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const throttleDoConnectDirectives = throttle(() => {
|
|
|
|
+ doConnectDirectives();
|
|
|
|
+}, 100);
|
|
|
|
+
|
|
function doConnectDirectives() {
|
|
function doConnectDirectives() {
|
|
videoWidth = Number(resolvingPower) ? Number(resolvingPower) : 720;
|
|
videoWidth = Number(resolvingPower) ? Number(resolvingPower) : 720;
|
|
videoHeight = videoWidth === 720 ? 1280 : 1920;
|
|
videoHeight = videoWidth === 720 ? 1280 : 1920;
|
|
@@ -54,6 +58,7 @@ function doConnectDirectives() {
|
|
wsss.binaryType = 'arraybuffer';
|
|
wsss.binaryType = 'arraybuffer';
|
|
|
|
|
|
wsss.onopen = function () {
|
|
wsss.onopen = function () {
|
|
|
|
+ errorTime = 0;
|
|
// 进入发起询问
|
|
// 进入发起询问
|
|
var pings2 = {
|
|
var pings2 = {
|
|
type: 'forwardMsg',
|
|
type: 'forwardMsg',
|
|
@@ -63,6 +68,7 @@ function doConnectDirectives() {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
wsss.send(JSON.stringify(pings2));
|
|
wsss.send(JSON.stringify(pings2));
|
|
|
|
+
|
|
wsss.send(
|
|
wsss.send(
|
|
JSON.stringify({
|
|
JSON.stringify({
|
|
type: 'getPhoneSize',
|
|
type: 'getPhoneSize',
|
|
@@ -70,20 +76,22 @@ function doConnectDirectives() {
|
|
);
|
|
);
|
|
};
|
|
};
|
|
wsss.onerror = function (e) {
|
|
wsss.onerror = function (e) {
|
|
- wsss.close();
|
|
|
|
- throttle(doConnectDirectives, 100);
|
|
|
|
- if (errorTime > 1000) {
|
|
|
|
- quit();
|
|
|
|
- }
|
|
|
|
|
|
+ // console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
|
|
|
|
+ wsss.close(1006);
|
|
|
|
+ // throttle(doConnectDirectives, 100);
|
|
|
|
+ // if (errorTime > 1000) {
|
|
|
|
+ // quit();
|
|
|
|
+ // }
|
|
};
|
|
};
|
|
wsss.onclose = function (e) {
|
|
wsss.onclose = function (e) {
|
|
- // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e.code);
|
|
|
|
|
|
+ // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e);
|
|
// new WebSocket(e.)
|
|
// new WebSocket(e.)
|
|
// doConnectDirectives();
|
|
// doConnectDirectives();
|
|
if (e.code === 1006) {
|
|
if (e.code === 1006) {
|
|
// 异常关闭,重连
|
|
// 异常关闭,重连
|
|
|
|
+ throttleDoConnectDirectives();
|
|
// doConnectDirectives();
|
|
// doConnectDirectives();
|
|
- throttle(doConnectDirectives, 100);
|
|
|
|
|
|
+ // throttle(doConnectDirectives, 100);
|
|
if (errorTime > 1000) {
|
|
if (errorTime > 1000) {
|
|
quit();
|
|
quit();
|
|
}
|
|
}
|