From 4babf1aa6cb50fde7558af902c9f096207b22679 Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Tue, 25 Jun 2024 09:48:42 +0800 Subject: [PATCH 1/4] 1 --- sdk/src/AppController.js | 5 +++-- sdk/src/KeyboardInput.js | 16 ++++++++-------- sdk/src/KeyboardListener.js | 7 ++++++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sdk/src/AppController.js b/sdk/src/AppController.js index e17a82c..a63b505 100644 --- a/sdk/src/AppController.js +++ b/sdk/src/AppController.js @@ -353,7 +353,7 @@ class AppController { initPlyerAndStart() { this.initPlayer(); if (this.player) { - if (this.options.keycodeInput && !this.options.isMobile) { + if (this.options.keycodeInput || this.isMobile) { this.keyboardListener = new KeyboardListener(this.options.containerId, this.send); } else { this.keyboardInput = new KeyboardInput(this.options.containerId, this.send, this.options.isMobile); @@ -369,7 +369,7 @@ class AppController { containerId: this.options.containerId, }); this.touchHandler.start(); - if (this.options.keycodeInput && !this.options.isMobile) { + if (this.options.keycodeInput || this.isMobile) { this.keyboardListener.start(this.touchHandler); } else { this.keyboardInput.getTouchHandler(this.touchHandler); @@ -1495,6 +1495,7 @@ class AppController { this.autoRotation && this.autoRotation.destroy(); this.keyboardInput && this.keyboardInput.destroy(); this.fullscreen && this.fullscreen.destroy(); + this.keyboardListener && this.keyboardListener.destroy(); // 停止传感器 this.deviceHardwareHandler && this.deviceHardwareHandler.handleSensorDisable(this.sensorMsgType.TYPE_ACCELEROMETER); this.deviceHardwareHandler && this.deviceHardwareHandler.handleSensorDisable(this.sensorMsgType.TYPE_GYROSCOPE); diff --git a/sdk/src/KeyboardInput.js b/sdk/src/KeyboardInput.js index 426934d..e1ef1d1 100644 --- a/sdk/src/KeyboardInput.js +++ b/sdk/src/KeyboardInput.js @@ -60,10 +60,11 @@ export default class KeyboardInput { opacity: 0; box-sizing: border-box; `; - - videoContainer.addEventListener("mouseup", (event) => { - this.onMouseUp(event); - }, true); + if(!this.isMobile) { + videoContainer.addEventListener("mouseup", (event)=>{ + this.onMouseUp(event) + }, true) + } this.util.bind(this.input, 'compositionstart', this.compositionstart.bind(this)); this.util.bind(this.input, 'compositionend', this.compositionend.bind(this)); this.util.bind(this.input, 'input', this.onInput.bind(this)); @@ -104,10 +105,6 @@ export default class KeyboardInput { this.onInput(); } - onInput() { - this.handleInputMsg(this.input.value, 'KEYBOARD_INPUT', PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.TEXT_UPDATE); - } - onInput() { if(!this.cnStart) { this.handleInputMsg(this.input.value, 'KEYBOARD_INPUT' , PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.IME_PASTE_FROM_PC_SDK); @@ -146,6 +143,9 @@ export default class KeyboardInput { destroy() { this.util.unbind(this.input, 'input'); this.util.unbind(this.input, 'keyup'); + this.util.unbind(this.input, 'keydown'); + this.util.unbind(this.input, 'compositionstart'); + this.util.unbind(this.input, 'compositionend'); this.inputContainer.remove(); this.inputContainer = null; } diff --git a/sdk/src/KeyboardListener.js b/sdk/src/KeyboardListener.js index f085650..43792b7 100644 --- a/sdk/src/KeyboardListener.js +++ b/sdk/src/KeyboardListener.js @@ -53,5 +53,10 @@ export default class KeyboardListener { cmdBuf.set(msgData, PACKAGE_HEADER_LENGTH + INPUT_HEADER_LENGTH); this.msgHandler(cmdBuf.buffer); - } + } + + destroy() { + this.util.unbind(this.input, 'keydown'); + this.util.unbind(this.input, 'keypress'); + } } \ No newline at end of file -- Gitee From 447e982c1fdb50158ebc250889b3d3a6f8aa1957 Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Thu, 27 Jun 2024 14:18:12 +0800 Subject: [PATCH 2/4] 1 --- sdk/demo/demo.html | 4 ++++ sdk/src/CPHCloudApp.js | 4 ++++ sdk/src/CloudApp.js | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index af06a31..5cd1576 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -603,6 +603,10 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. document.getElementById("loading").style.display = normalStates.includes(state) ? 'none' : 'block'; showAlertModal(data); startsuccessCallBack(data); + + if(state === STATE_CONFIG.RESUMED) { + cloudapp.requestIFrame(); + } }); cloudapp.on("netStateChange", function (event, data) { diff --git a/sdk/src/CPHCloudApp.js b/sdk/src/CPHCloudApp.js index 707c6fb..cfdefcc 100644 --- a/sdk/src/CPHCloudApp.js +++ b/sdk/src/CPHCloudApp.js @@ -334,6 +334,10 @@ class CPHCloudApp { this.appController.resumeCloudPhone(); } + requestIFrame() { + this.appController.requestIFrame(); + } + reconnect() { this.appController.reconnect(); } diff --git a/sdk/src/CloudApp.js b/sdk/src/CloudApp.js index e118612..3a7c14a 100644 --- a/sdk/src/CloudApp.js +++ b/sdk/src/CloudApp.js @@ -44,6 +44,10 @@ class CloudApp { this.channel.pause(); } + requestIFrame() { + this.channel.requestIFrame(); + } + resume() { this.channel.resume(); } -- Gitee From b11c1db19fa87428f2f7b97a458c8165cb401e5a Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Tue, 2 Jul 2024 09:30:56 +0800 Subject: [PATCH 3/4] 1 --- sdk/demo/demo.html | 10 +++++++++- sdk/src/AppController.js | 7 ++++++- sdk/src/AutoRotation.js | 2 +- sdk/src/DirectionHandler.js | 4 ++-- sdk/src/config/protocolConfig.js | 1 + 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index 5cd1576..56c9ea8 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -515,6 +515,14 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. } } + function uuid_32() { + let uuid = ''; + for(i = 0; i < 32; i++) { + uuid += Math.floor(Math.random()*10) + } + return uuid + '32uuid' + } + function connectCloudPhone() { var cloudPhoneHost = JSON.parse(sessionStorage.getItem('cloudPhoneHost')); var phoneInfo = JSON.parse(sessionStorage.getItem('phoneInfo')); @@ -528,7 +536,7 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. var cloudPhoneParams = { ip: cloudIp, port: cloudPort, - session_id: '32uuid'.padStart(32, '0'), + session_id: uuid_32(), background_timeout: '60', available_playtime: '6000', touch_timeout: 600, diff --git a/sdk/src/AppController.js b/sdk/src/AppController.js index a63b505..9c130bd 100644 --- a/sdk/src/AppController.js +++ b/sdk/src/AppController.js @@ -89,7 +89,8 @@ const APP_STATE_ERROR_CODE_TIP = { 3584: '试玩时间已到', 2560: '与服务器连接出现异常', 3840: '由于您长时间未操作游戏,服务断开', - 4096: '切换后台超时' + 4096: '切换后台超时', + 8960: '云机在其他设备上被连接,本次连接退出' }; const DEFAULT_VALUME_VALUE = 50; const WEBSOCKET_READY_STATE = { @@ -700,6 +701,10 @@ class AppController { Logger.debug('Receive failed response, disconnect'); this.disconnect(); break; + case codeConfig.PHONE_CONNECTED: + Logger.debug('Phone has connected, disconnect'); + this.disconnect(); + break; case codeConfig.PLAY_TIMEOUT: Logger.debug('Play timeout, disconnect'); this.disconnect(); diff --git a/sdk/src/AutoRotation.js b/sdk/src/AutoRotation.js index 27b5430..ec565bd 100644 --- a/sdk/src/AutoRotation.js +++ b/sdk/src/AutoRotation.js @@ -296,6 +296,6 @@ export default class AutoRotation { } getDeviceOrientation() { - return window.screen.orientation.angle; + return window?.screen?.orientation?.angle || window.orientation; } } diff --git a/sdk/src/DirectionHandler.js b/sdk/src/DirectionHandler.js index f17f0f2..324c5e9 100644 --- a/sdk/src/DirectionHandler.js +++ b/sdk/src/DirectionHandler.js @@ -569,7 +569,7 @@ class DirectionHandler { // 旋转前需要先取消旋转,避免叠加旋转 this.cancelTransform(); if (this.options.isMobile) { - const deviceOrientation = window.screen.orientation.angle; + const deviceOrientation = window.screen.orientation.angle || window.orientation; if ([DEVICE_ORIENTATION_ANGLES.PORTRAIT,DEVICE_ORIENTATION_ANGLES.REVERSE_PORTRAIT].includes(deviceOrientation)) { this.portraitMobile(); } else if ([DEVICE_ORIENTATION_ANGLES.LANDSCAPE, DEVICE_ORIENTATION_ANGLES.REVERSE_LANDSCAPE].includes(deviceOrientation)) { @@ -692,7 +692,7 @@ class DirectionHandler { setTimeout(() => { let width = document.documentElement.clientWidth; let height = document.documentElement.clientHeight; - const deviceOrientation = window.screen.orientation.angle; + const deviceOrientation = window.screen.orientation.angle || window.orientation; if ([DEVICE_ORIENTATION_ANGLES.PORTRAIT,DEVICE_ORIENTATION_ANGLES.REVERSE_PORTRAIT].includes(deviceOrientation)) { if ([PROTOCOL_CONFIG.ORIENTATION[0], PROTOCOL_CONFIG.ORIENTATION[16]].includes(this.orientation)) { playerWidth = width; diff --git a/sdk/src/config/protocolConfig.js b/sdk/src/config/protocolConfig.js index 5a5d8e0..da6c1e6 100644 --- a/sdk/src/config/protocolConfig.js +++ b/sdk/src/config/protocolConfig.js @@ -101,6 +101,7 @@ const PROTOCOL_CONFIG = { H265_NOT_SUPPORT: 0x1102, VERIFY_SESSION_ID_INVALID: 0x0607, INVALID_OPERATION: 0xFFFF, + PHONE_CONNECTED: 0x2300, }, ACTIONS_TYPE: { DOWN: 0, -- Gitee From 69ff4c2555b13d79b2a97b3ba8d8f44fa9c6b627 Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Tue, 2 Jul 2024 10:11:37 +0800 Subject: [PATCH 4/4] 1 --- sdk/demo/demo.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index 56c9ea8..8aaaf45 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -517,7 +517,7 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. function uuid_32() { let uuid = ''; - for(i = 0; i < 32; i++) { + for(i = 0; i < 26; i++) { uuid += Math.floor(Math.random()*10) } return uuid + '32uuid' -- Gitee