@@ -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 */
0 commit comments