|
@@ -26,29 +26,30 @@ var isAuth = parameters['authPhone']; // 是否是获取的云手机
|
|
var wsss;
|
|
var wsss;
|
|
var errorTime = 0;
|
|
var errorTime = 0;
|
|
var first = true;
|
|
var first = true;
|
|
|
|
+let intervalerPing = null
|
|
function changIsControl(value) {
|
|
function changIsControl(value) {
|
|
isControl = value;
|
|
isControl = value;
|
|
// if(){}
|
|
// if(){}
|
|
$('#open-set-phone-size-dialog-btn').attr('hidden', !value);
|
|
$('#open-set-phone-size-dialog-btn').attr('hidden', !value);
|
|
}
|
|
}
|
|
|
|
|
|
-function throttle(fn, delay) {
|
|
|
|
- var flag = true;
|
|
|
|
- return () => {
|
|
|
|
- if (!flag) return;
|
|
|
|
- flag = false;
|
|
|
|
- errorTime += delay;
|
|
|
|
- timer = setTimeout(() => {
|
|
|
|
- fn();
|
|
|
|
- flag = true;
|
|
|
|
- }, delay);
|
|
|
|
- };
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const throttleDoConnectDirectives = throttle(() => {
|
|
|
|
- doConnectDirectives();
|
|
|
|
-}, 100);
|
|
|
|
|
|
+let directivesTimeInterval = 1
|
|
|
|
+// function throttle(fn, delay) {
|
|
|
|
+// var flag = true;
|
|
|
|
+// return () => {
|
|
|
|
+// if (!flag) return;
|
|
|
|
+// flag = false;
|
|
|
|
+// errorTime += delay;
|
|
|
|
+// timer = setTimeout(() => {
|
|
|
|
+// fn();
|
|
|
|
+// flag = true;
|
|
|
|
+// }, 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;
|
|
@@ -56,7 +57,11 @@ function doConnectDirectives() {
|
|
wsss.binaryType = 'arraybuffer';
|
|
wsss.binaryType = 'arraybuffer';
|
|
|
|
|
|
wsss.onopen = function () {
|
|
wsss.onopen = function () {
|
|
|
|
+ clearInterval(intervalerPing)
|
|
// 获取虚拟场景状态
|
|
// 获取虚拟场景状态
|
|
|
|
+ intervalerPing = setInterval(() => {
|
|
|
|
+ wsss.send('ping');
|
|
|
|
+ }, 3000)
|
|
errorTime = 0;
|
|
errorTime = 0;
|
|
var pings = { type: 'getVsStatus' };
|
|
var pings = { type: 'getVsStatus' };
|
|
wsss.send(JSON.stringify(pings));
|
|
wsss.send(JSON.stringify(pings));
|
|
@@ -67,6 +72,8 @@ function doConnectDirectives() {
|
|
type: 'bitRate',
|
|
type: 'bitRate',
|
|
};
|
|
};
|
|
wsss.send(JSON.stringify(bitRate));
|
|
wsss.send(JSON.stringify(bitRate));
|
|
|
|
+ // 键盘透传 2 是用云机内置的
|
|
|
|
+ wsss.send(JSON.stringify({ data: { type: 2 }, type: 'InputMethod' }));
|
|
// // 进入发起询问
|
|
// // 进入发起询问
|
|
// var pings2 = {
|
|
// var pings2 = {
|
|
// type: 'forwardMsg',
|
|
// type: 'forwardMsg',
|
|
@@ -85,26 +92,37 @@ function doConnectDirectives() {
|
|
);
|
|
);
|
|
};
|
|
};
|
|
wsss.onerror = function (e) {
|
|
wsss.onerror = function (e) {
|
|
|
|
+ clearInterval(intervalerPing)
|
|
|
|
+ if(!quitBool) return
|
|
|
|
+ if (directivesTimeInterval > 7) {
|
|
|
|
+ quit();
|
|
|
|
+ return
|
|
|
|
+ }
|
|
// console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
|
|
// console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
|
|
- wsss.close(1006);
|
|
|
|
|
|
+ // wsss.close(1006);
|
|
// throttle(doConnectDirectives, 100);
|
|
// throttle(doConnectDirectives, 100);
|
|
// if (errorTime > 1000) {
|
|
// if (errorTime > 1000) {
|
|
// quit();
|
|
// quit();
|
|
// }
|
|
// }
|
|
|
|
+ directivesTimeInterval++
|
|
|
|
+ // 异常关闭,重连
|
|
|
|
+ doConnectDirectives();
|
|
|
|
+ // doConnectDirectives();
|
|
|
|
+ // throttle(doConnectDirectives, 100);
|
|
};
|
|
};
|
|
wsss.onclose = function (e) {
|
|
wsss.onclose = function (e) {
|
|
// console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e);
|
|
// console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e);
|
|
// new WebSocket(e.)
|
|
// new WebSocket(e.)
|
|
// doConnectDirectives();
|
|
// doConnectDirectives();
|
|
- if (e.code === 1006) {
|
|
|
|
- // 异常关闭,重连
|
|
|
|
- throttleDoConnectDirectives();
|
|
|
|
- // doConnectDirectives();
|
|
|
|
- // throttle(doConnectDirectives, 100);
|
|
|
|
- if (errorTime > 1000) {
|
|
|
|
- quit();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // if (e.code === 1006) {
|
|
|
|
+ // // 异常关闭,重连
|
|
|
|
+ // throttleDoConnectDirectives();
|
|
|
|
+ // // doConnectDirectives();
|
|
|
|
+ // // throttle(doConnectDirectives, 100);
|
|
|
|
+ // if (errorTime > 1000) {
|
|
|
|
+ // quit();
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
};
|
|
};
|
|
wsss.onmessage = function (res) {
|
|
wsss.onmessage = function (res) {
|
|
var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
|
|
var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
|
|
@@ -281,7 +299,7 @@ function doConnectDirectives() {
|
|
(window.currentPhoneSize.width !==
|
|
(window.currentPhoneSize.width !==
|
|
Math.min(result.data.width, result.data.height) ||
|
|
Math.min(result.data.width, result.data.height) ||
|
|
window.currentPhoneSize.height !==
|
|
window.currentPhoneSize.height !==
|
|
- Math.max(result.data.width, result.data.height) ||
|
|
|
|
|
|
+ Math.max(result.data.width, result.data.height) ||
|
|
window.currentPhoneSize.dpi !== result.data.dpi)
|
|
window.currentPhoneSize.dpi !== result.data.dpi)
|
|
) {
|
|
) {
|
|
// 获取到的分辨率与当前分辨率不符
|
|
// 获取到的分辨率与当前分辨率不符
|