Skip to content

Commit 104d4cd

Browse files
author
ranpeng
committed
v1.1.21
1 parent 00e5557 commit 104d4cd

File tree

4 files changed

+117
-21
lines changed

4 files changed

+117
-21
lines changed

changelog.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
### [1.1.21](https://github.com/tencentyun/cloudgame-js-sdk/releases/tag/v1.1.21)@2024.01.04
2+
3+
**新增**
4+
5+
- 新增部分页面日志
6+
- 新增init 参数,remoteDesktopResolution
7+
- 新增init 参数,enableEventIntercept 用于关闭事件拦截
8+
- 华为浏览器新增音频标签
9+
10+
**变更**
11+
12+
- inbound-rtp 增加 JitterBuffer 计算
13+
14+
**修复**
15+
16+
- touchcancel 清理 touchList
17+
- 修复idleThreshold 未设置,回调不成功问题
18+
19+
120
### [1.1.20](https://github.com/tencentyun/cloudgame-js-sdk/releases/tag/v1.1.20)@2023.11.23
221

322
**新增**

dist/tcg-sdk/index.d.ts

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,9 @@ export interface InitConfig {
678678
*/
679679
clickBodyToPlay?: boolean;
680680
/**
681-
* 用户操作空闲时间阈值,单位为秒,默认值:300s 空闲超过这个时间将触发 onNetworkChange 事件,消息为 {status: 'idle', times: 1}
681+
* 用户操作空闲时间阈值,单位为秒,默认值:300s 空闲超过这个时间将触发 onEvent 事件,消息为 {type: 'idle', data: {times: 1}}
682+
*
683+
* **可在回调中调用 TCGSDK.destroy() 释放并发**
682684
*
683685
* @default 300
684686
*/
@@ -694,7 +696,7 @@ export interface InitConfig {
694696
/**
695697
* 是否自动重连,会在弱网,或帧率持续掉 0所导致的断连时,主动重连
696698
*
697-
* 重连策略:每5秒尝试一次,最多重连5次
699+
* 重连策略:每6秒尝试一次,最多重连10次
698700
*
699701
* @default true
700702
*/
@@ -760,13 +762,19 @@ export interface InitConfig {
760762
*/
761763
bgImgUrl?: string;
762764
/**
763-
* 默认鼠标图片 https/http 地址,不传默认展示一个宽高 3px 的圆形小点,传 '',不展示。
765+
* 默认不展示
766+
*
767+
* 鼠标图片格式 https/http 地址
768+
*
769+
* 移动端传 'dot' 展示一个宽高 3px 的圆形小点。
770+
*
771+
* @default null
764772
*/
765773
defaultCursorImgUrl?: string;
766774
/**
767775
* 云上应用交互模式,支持鼠标 或者 触摸
768776
*
769-
* **该参数建议移动端使用,PC 端设置该参数会导致鼠标锁定**
777+
* **该参数建议移动端使用**
770778
*
771779
* @default 'cursor'
772780
*/
@@ -776,7 +784,7 @@ export interface InitConfig {
776784
*
777785
* **该接口适用PC 端,通常在云端 input 框 focus 时候使用**
778786
*
779-
* @default false
787+
* @default true
780788
*/
781789
enablePaste?: boolean;
782790
// /**
@@ -795,6 +803,25 @@ export interface InitConfig {
795803
* @default true
796804
*/
797805
enableMousemoveV2?: boolean;
806+
/**
807+
* 初始化云端桌面分辨率
808+
*
809+
* **可通过 TCGSDK.getPageSize() 获取页面 width,height 来实现自适应分辨率(移动端可将 width * 2,height * 2 保证画面清晰)**
810+
*
811+
* @default null
812+
*/
813+
remoteDesktopResolution?: {
814+
width: number;
815+
height: number;
816+
};
817+
/**
818+
* 是否开启事件拦截
819+
*
820+
* 拦截鼠标/键盘等事件,只针对云渲染节点操作时才向云端发送指令。
821+
*
822+
* @default true
823+
*/
824+
enableEventIntercept?: boolean;
798825
/**
799826
* 初始化完毕的回调,触发此回调之后才能调用后面的 API
800827
*
@@ -825,7 +852,7 @@ export interface InitConfig {
825852
*/
826853
onConnectSuccess?: (response: OnConnectSuccessResponse) => void;
827854
/**
828-
* 连接失败回调,调用 start 接口成功后才会触发
855+
* 连接失败回调,连接断开,重连中会回调该接口
829856
*
830857
* 通常重连时间超过两分钟(例如连接断开/移动端切后台,两分钟后触发重连)
831858
* 系统会自动回收实例,表现为返回 code > 0,建议该情况下 重新init + createSession
@@ -872,7 +899,9 @@ export interface InitConfig {
872899
/**
873900
* 断开/被踢触发此回调,调用 start 接口成功后才会触发
874901
*
875-
* 如果开启自动重连即init 参数 reconnect: true,点开连接也会调用此回调,可根据对应code 判断是否需要刷新页面(window.location.reload())
902+
* 当出现 -1 时候,如果设置了 init 参数 `reconnect: true`(默认值 true) 不用任何操作,SDK 会主动重连,未设置需要调用 TCGSDK.reconnect()
903+
*
904+
* 如果持续链接不上,可以看回调 onConnectFail 相关错误码,在里面完善相关逻辑
876905
*
877906
* @function
878907
* @param {Object} response - onDisconnect 回调函数的 response
@@ -881,15 +910,12 @@ export interface InitConfig {
881910
* | code | Description |
882911
* | ------- | --------------------------------------------------------------- |
883912
* | -2 | 创建local offer 失败,需要重新init + createSession |
884-
* | -1 | 需要重连,通常出现在码率掉0,收不到推流,连接超时,ice 断开,可以尝试重连 |
913+
* | -1 | 需要重连,通常出现在码率掉0,收不到推流,连接超时,ice 断开,SDK 会自动重连 |
885914
* | 0 | 主动关闭 |
886915
* | 1 | 用户重复连接(该消息不可靠) |
887916
* | 2 | 用户心跳超时,webrtc服务端主动断开,这个消息有可能丢失 init + createSession |
888917
* @param {string} response.msg - message
889918
*
890-
* @description
891-
* 当出现 -1 时候,如果设置了 init 参数 `reconnect: true`(默认值 true) 不用任何操作,SDK 会主动重连,未设置需要调用 TCGSDK.reconnect()
892-
* 如果持续链接不上,可以看回调 onConnectFail 相关错误嘛,在里面完善相关逻辑
893919
*/
894920
onDisconnect?: (response: OnDisconnectResponse) => void;
895921
/**
@@ -932,7 +958,7 @@ export interface InitConfig {
932958
* // console.log('onTouchEvent', res);
933959
* // 针对单指触控操作
934960
* if (res.length === 1) {
935-
* const { id, type, pageX, pageY } = res.pop();
961+
* const [{ id, type, pageX, pageY }] = res;
936962
* // console.log('onTouchEvent', id, type, pageX, pageY);
937963
* TCGSDK.mouseMove(id, type, pageX, pageY);
938964
* if (type === 'touchstart') {
@@ -944,7 +970,7 @@ export interface InitConfig {
944970
* }
945971
* // 针对双指缩放操作,这里双指模拟了PC 的鼠标滚轮事件
946972
* if (res.length === 2) {
947-
* const [{ pageX: oneX, pageY: oneY }, { pageX: twoX, pageY: twoY }] = res;
973+
* const [{ pageX: oneX, pageY: oneY, type: oneType }, { pageX: twoX, pageY: twoY, type: twoType }] = res;
948974
*
949975
* const currentX = Math.ceil(Math.abs(oneX - twoX));
950976
* const currentY = Math.ceil(Math.abs(oneY - twoY));
@@ -963,6 +989,16 @@ export interface InitConfig {
963989
* lastX = currentX;
964990
* lastY = currentY;
965991
* }
992+
*
993+
* // 双指离开后,发送一次鼠标抬起操作
994+
* if (
995+
* oneType === 'touchend' ||
996+
* oneType === 'touchcancel' ||
997+
* twoType === 'touchend' ||
998+
* twoType === 'touchcancel'
999+
* ) {
1000+
* TCGSDK.sendMouseEvent({ type: 'mouseleft', down: false });
1001+
* }
9661002
* }
9671003
* }
9681004
*/

dist/tcg-sdk/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tcg-sdk/index_en.d.ts

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,9 @@ export interface InitConfig {
680680
*/
681681
clickBodyToPlay?: boolean;
682682
/**
683-
* User no action threshold, in seconds. Default value 300s, it will callback on onNetworkChange witt message `{status: 'idle', times: 1}`
683+
* User no action threshold, in seconds. Default value 300s, it will callback on onEvent with message `{type: 'idle', data: {times: 1}}`
684+
*
685+
* **Instance can be released in the callback by calling TCGSDK.destroy()**
684686
*
685687
* @default 300
686688
*/
@@ -694,7 +696,7 @@ export interface InitConfig {
694696
/**
695697
* Whether to enable auto reconnect. It will happen when FPS is 0 for 10s or first connect failed.
696698
*
697-
* Rule: Attempts every 5 seconds, maximum 5 times
699+
* Rule: Attempts every 6 seconds, maximum 10 times
698700
*
699701
* @default true
700702
*/
@@ -766,7 +768,13 @@ export interface InitConfig {
766768
*/
767769
bgImgUrl?: string;
768770
/**
769-
* Default cursor image(https/http url), default is a 3px dots, pass '' does not show cursor.
771+
* Default does not show cursor.
772+
*
773+
* Default cursor image(https/http url)
774+
*
775+
* Pass 'dot' to show a 3px blue dot in mobile.
776+
*
777+
* @default null
770778
*/
771779
defaultCursorImgUrl?: string;
772780
/**
@@ -780,7 +788,7 @@ export interface InitConfig {
780788
*
781789
* **This method is usually used when the cloud input box is focused.**
782790
*
783-
* @default false
791+
* @default true
784792
*/
785793
enablePaste?: boolean;
786794
/**
@@ -791,6 +799,25 @@ export interface InitConfig {
791799
* @default true
792800
*/
793801
enableMousemoveV2?: boolean;
802+
/**
803+
* Initialize Cloud Desktop Resolution
804+
*
805+
* **You can use TCGSDK.getPageSize() to get the width and height of the page to adapt resolution (for mobile, you can set the width*2 and height*2 to ensure a clear resolution).**
806+
*
807+
* @default null
808+
*/
809+
remoteDesktopResolution?: {
810+
width: number;
811+
height: number;
812+
};
813+
/**
814+
* Whether to enable event interception
815+
*
816+
* Intercept events such as mouse/keyboard. Send commands to the cloud only for cloud rendering nodes.
817+
*
818+
* @default true
819+
*/
820+
enableEventIntercept?: boolean;
794821
/**
795822
*
796823
* Init success callback
@@ -823,7 +850,11 @@ export interface InitConfig {
823850
*/
824851
onConnectSuccess?: (response: OnConnectSuccessResponse) => void;
825852
/**
826-
* Connect failed callback, it will trigger after call `TCGSDK.start()`.
853+
* Connect failed callback.
854+
*
855+
* Reconnection take longer than two minutes (e.g. connection disconnected/mobile switch to background, reconnection triggered after two minutes)
856+
* CAR backend will automatically destroy the instance and return code > 0. It is recommended to init + createSession again in this case.
857+
*
827858
*
828859
* @function
829860
* @param {Object} response - onConnectFail response
@@ -922,7 +953,7 @@ export interface InitConfig {
922953
* // console.log('onTouchEvent', res);
923954
* // Single finger
924955
* if (res.length === 1) {
925-
* const { id, type, pageX, pageY } = res.pop();
956+
* const [{ id, type, pageX, pageY }] = res;
926957
* // console.log('onTouchEvent', id, type, pageX, pageY);
927958
* TCGSDK.mouseMove(id, type, pageX, pageY);
928959
* if (type === 'touchstart') {
@@ -934,7 +965,7 @@ export interface InitConfig {
934965
* }
935966
* // Multi-finger, simulate the mouse wheel event of the PC
936967
* if (res.length === 2) {
937-
* const [{ pageX: oneX, pageY: oneY }, { pageX: twoX, pageY: twoY }] = res;
968+
* const [{ pageX: oneX, pageY: oneY, type: oneType }, { pageX: twoX, pageY: twoY, type: twoType }] = res;
938969
*
939970
* const currentX = Math.ceil(Math.abs(oneX - twoX));
940971
* const currentY = Math.ceil(Math.abs(oneY - twoY));
@@ -953,6 +984,16 @@ export interface InitConfig {
953984
* lastX = currentX;
954985
* lastY = currentY;
955986
* }
987+
*
988+
* // Sends a mouse up action after two fingers are touchend or touchcancel
989+
* if (
990+
* oneType === 'touchend' ||
991+
* oneType === 'touchcancel' ||
992+
* twoType === 'touchend' ||
993+
* twoType === 'touchcancel'
994+
* ) {
995+
* TCGSDK.sendMouseEvent({ type: 'mouseleft', down: false });
996+
* }
956997
* }
957998
* }
958999
*/

0 commit comments

Comments
 (0)