TCGSDK InitConfig related configuration.
Members
appid :number
Tencent cloud APPID, Optional
Type:
- number
mount :string
Cloud rendering mount point(HTML element ID).
Type:
- string
mic :boolean|MicProfileConstraints
- Default Value:
- false
Whether to enable mic
Type:
- boolean | MicProfileConstraints
camera :boolean|CameraProfileConstraints|CameraProfileType
- Default Value:
- false
Whether to enable camera
Type:
- boolean | CameraProfileConstraints | CameraProfileType
tabletMode :boolean
- Default Value:
- false
Enables/Disables the cursor sliding mode. This API is generally used in scenarios where there is an offset between the displayed cursor and the actual touch point.
Can not use it on PC
Type:
- boolean
mobileGame :boolean
- Default Value:
- false
Mobile Game
Type:
- boolean
mobileVpx :boolean
- Default Value:
- false
Whether to enable VPX encoding
Type:
- boolean
cursorMode :number
- Default Value:
- 0
Cursor mode valid values:
mode=0: Fixed cursor image rendered on the page, if the default mouse image is not set, the system mouse will be used.
mode=1: Cursor image delivered from the cloud and rendered by the browser page
mode=2: (Not recommended) Cursor image rendered on the cloud page. In this case, the locally rendered cursor will be hidden. This mode has the best compatibility but causes a delay in cursor movement.
Type:
- number
clickToFullscreen :boolean
- Default Value:
- false
Whether to enable click any point to fullscreen.
Type:
- boolean
clickBodyToPlay :boolean
- Default Value:
- true
Whether to enable click any point to play video.
Type:
- boolean
idleThreshold :number
- Default Value:
- 300
User no action threshold, in seconds. Default value 300s, it will callback on onEvent with message {type: 'idle', data: {times: 1}}
Instance can be released in the callback by calling TCGSDK.destroy()
Type:
- number
keepLastFrame :boolean
- Default Value:
- false
Keep last frame image when destroy. Mac safari/ios webview does not work.
Type:
- boolean
reconnect :boolean
- Default Value:
- true
Whether to enable auto reconnect. It will happen when FPS is 0 for 10s or first connect failed.
Rule: Attempts every 6 seconds, maximum 10 times
Type:
- boolean
showLoading :boolean
- Default Value:
- true
Whether to show loading.
Type:
- boolean
loadingText :string
- Default Value:
- '正在启动云渲染'
Loading text
Type:
- string
restartText :string
- Default Value:
- '重新连接'
Restart button text
Type:
- string
autoRotateContainer :boolean
- Default Value:
- false
Whether to rotate the entire HTML view. Default value: `false.
Type:
- boolean
autoRotateMountPoint :boolean
- Default Value:
- false
Whether to rotate the mountPoint
node. Default value: false
.
Type:
- boolean
fullVideoToScreen :boolean
- Default Value:
- true
When mount point size(width/height) bigger than cloud stream.
true
Stretch video size and fit on short edge.
false
Do not stretch the video, keep the original cloud resolution.
Type:
- boolean
debugSetting :DebugSettingParams
Enables/Disables the debugging mode. If it is enabled, logs will be printed in the console.
Type:
webDraftLevel :number
- Default Value:
- 0
0: Turn off mouse high frequency sampling
1: Open mouse high frequency sampling
2: Open mouse high frequency sampling and send as package
3: Limit the length of the packet, and lose more
Type:
- number
forceShowCursor :boolean
- Default Value:
- false
Force display of mouse
Type:
- boolean
bgImgUrl :string
Sets background image for web container, not cloud desktop background image.
Type:
- string
defaultCursorImgUrl :string
- Default Value:
- null
Default does not show cursor.
Default cursor image(https/http url)
Pass 'dot' to show a 3px blue dot in mobile.
Type:
- string
clientInteractMode :'cursor'|'touch'
- Default Value:
- 'cursor'
CLoud client interaction mode, support mouse or touch
Type:
- 'cursor' | 'touch'
enablePaste :boolean
- Default Value:
- true
Whether to hijack Ctrl/Cmd + V. When a user uses the paste feature, the content in the local clipboard will be sent to the cloud directly.
This method is usually used when the cloud input box is focused.
Type:
- boolean
enableMousemoveV2 :boolean
- Default Value:
- true
Whether to enable cloud computing mouse
Could be smoother
Type:
- boolean
remoteDesktopResolution :object
- Default Value:
- null
Properties:
Name | Type | Description |
---|---|---|
width |
number | |
height |
number |
Initialize Cloud Desktop Resolution
You can use TCGSDK.getPageSize() to get the width and height of the page to adapt resolution (for mobile, you can set the width2 and height2 to ensure a clear resolution).
Type:
- object
enableEventIntercept :boolean
- Default Value:
- true
Whether to enable event interception
Intercept events such as mouse/keyboard. Send commands to the cloud only for cloud rendering nodes.
Type:
- boolean
Methods
onInitSuccess(response) → {function}
Init success callback
CreateSession in this callback.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | OnInitSuccess response Properties
|
Returns:
- Type
- function
onConnectSuccess(response) → {function}
Connect success callback, it will trigger after call TCGSDK.start()
.
We recommend use other API after this callback. Like follow methods:
createCustomDataChannel
- Use plugin, lick
new joystick()
. setRemoteDesktopResolution
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onConnectSuccess response Properties
|
Returns:
- Type
- function
onConnectFail(response) → {function}
Connect failed callback.
Reconnection take longer than two minutes (e.g. connection disconnected/mobile switch to background, reconnection triggered after two minutes) CAR backend will automatically destroy the instance and return code > 0. It is recommended to init + createSession again in this case.
Parameters:
Name | Type | Description | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onConnectFail response Properties
|
Returns:
- Type
- function
onWebrtcStatusChange(response) → {function}
Webrtc status callback, it will trigger after call TCGSDK.start()
.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onWebrtcStatusChange response Properties
|
Returns:
- Type
- function
onDisconnect(response) → {function}
User disconnect or disconnect from server, it will trigger after call TCGSDK.start()
.
if sets init param reconnect: true
, this callback will also be trigger, You can judge whether the page needs to be refreshed according to the corresponding code.
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onDisconnect response Properties
|
Returns:
- Type
- function
onNetworkChange(response) → {function}
Network status change callback
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onNetworkChange response Properties
|
Returns:
- Type
- function
onTouchEvent(response) → {function}
Touch event callback, it will trigger after call TCGSDK.start()
.
Response is OnTouchEventResponse[], Corresponds to the number of touch points on the current screen, multi-finger operation can be judged according to the length of the array.
Example
onTouchEvent: async (res) => {
// console.log('onTouchEvent', res);
// Single finger
if (res.length === 1) {
const [{ id, type, pageX, pageY }] = res;
// console.log('onTouchEvent', id, type, pageX, pageY);
TCGSDK.mouseMove(id, type, pageX, pageY);
if (type === 'touchstart') {
TCGSDK.sendMouseEvent({ type: 'mouseleft', down: true });
}
if (type === 'touchend' || type === 'touchcancel') {
TCGSDK.sendMouseEvent({ type: 'mouseleft', down: false });
}
}
// Multi-finger, simulate the mouse wheel event of the PC
if (res.length === 2) {
const [{ pageX: oneX, pageY: oneY, type: oneType }, { pageX: twoX, pageY: twoY, type: twoType }] = res;
const currentX = Math.ceil(Math.abs(oneX - twoX));
const currentY = Math.ceil(Math.abs(oneY - twoY));
// lastX, lastY, can be defined globally, like: let lastX = null, lastY = null
lastX || (lastX = currentX);
lastY || (lastY = currentY);
if (lastX && currentX - lastX < 0 && lastY && currentY - lastY < 0) {
TCGSDK.sendMouseEvent({ type: 'mousescroll', delta: 1 });
lastX = currentX;
lastY = currentY;
}
if (lastX && currentX - lastX > 0 && lastY && currentY - lastY > 0) {
TCGSDK.sendMouseEvent({ type: 'mousescroll', delta: -1 });
lastX = currentX;
lastY = currentY;
}
// Sends a mouse up action after two fingers are touchend or touchcancel
if (
oneType === 'touchend' ||
oneType === 'touchcancel' ||
twoType === 'touchend' ||
twoType === 'touchcancel'
) {
TCGSDK.sendMouseEvent({ type: 'mouseleft', down: false });
}
}
}
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Array.<Object> | onTouchEvent response Properties
|
Returns:
- Type
- function
onDoubleTap() → {function}
Only for mobile, double tao callback(same as onTouchEvent)
Returns:
- Type
- function
onGameStartComplete(response) → {function}
Game start success callback
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onGameStartComplete response Properties
|
Returns:
- Type
- function
onGameStop(response) → {function}
Game stop callback
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onGameStop response Properties
|
Returns:
- Type
- function
onLoadGameArchive(response) → {function}
Game archive loading callback, will continue to call back size
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onLoadGameArchive response Properties
|
Returns:
- Type
- function
onSaveGameArchive(response) → {function}
游戏保存存档回调
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onLoadGameArchive response Properties
|
Returns:
- Type
- function
onInputStatusChange(response) → {function}
When the cloud input state changes, it will be triggered, You can judge whether the input box is focused.
This callback might be called twice, once when the mouseleft clicks down, and once when the mouseleft clicks up.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onInputStatusChange response Properties
|
Returns:
- Type
- function
onGamepadConnectChange(response) → {function}
Gamepad connection status callback
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onGamepadConnectChange response Properties
|
Returns:
- Type
- function
onCursorShowStatChange(response) → {function}
Cursor show/hide, only trigger when status changed.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onCursorShowStatChange response Properties
|
Returns:
- Type
- function
onOrientationChange(response) → {function}
Orientation change callback.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
response |
Object | onOrientationChange response Properties
|
Returns:
- Type
- function
onVisibilityChange(response) → {function}
Page visibility changes.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
response |
Object | onVisibilityChange response Properties
|
Returns:
- Type
- function
onConfigurationChange(response) → {function}
Cloud config changed, only trigger when status changed.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onConfigurationChange response Properties
|
Returns:
- Type
- function
onRemoteScreenResolutionChange(response) → {function}
Cloud screen resolution changed.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onRemoteScreenResolutionChange response Properties
|
Returns:
- Type
- function
onVideoStreamConfigChange(response) → {function}
Video stream resolution changed.
The difference between onRemoteScreenResolutionChange and onRemoteScreenResolutionChange is that the former is the resolution of the cloud screen/application, and the latter is the resolution of the stream decoded.
There may be a case where the screen/application resolution is set to 1280720, but the resolution of the push stream is 19201080.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onVideoStreamConfigChange response Properties
|
Returns:
- Type
- function
onDeviceChange() → {function}
Connected devices have changed and can be get by navigator.mediaDevices.enumerateDevices()
.
Returns:
- Type
- function
onGetUserMediaStatusChange(response) → {function}
User media callback
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onGetUserMediaStatusChange response Properties
|
Returns:
- Type
- function
onEvent(response) → {function}
Event callback
It is mainly used to callback whether the autoplay is successful or not.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onEvent response Properties
|
Returns:
- Type
- function
onStreamPushStateChange(response) → {function}
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
response |
Object | onStreamPushStateChange response Properties
|
Returns:
- Type
- function
onMultiPlayerChange(response) → {function}
Multi-player cloud game
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response |
Object | onMultiPlayerChange response Properties
|
Returns:
- Type
- function
onLog(response) → {function}
Log callback, same as setLogHandler
Parameters:
Name | Type | Description |
---|---|---|
response |
string |
Returns:
- Type
- function