TCGSDK

The TCG(Tencent Cloud Gaming) JavaScript SDK (TCGSDK) is used to develop PaaS cloud rendering applications. It is exported as a singleton, adopts configuration and callback registration methods, and provides mouse/keyboard, audio/video, and game process control APIs as detailed below.

Methods

init(config) → {void}

Parameters:
Name Type Description
config InitConfig

The entry file of TCGSDK. We recommend you call other TCGSDK methods in the onInitSuccess or onConnectSuccess callback function in init.

Returns:
Type
void

getInitOptions() → {InitConfig}

Gets the initialization parameter InitConfig

Returns:
Type
InitConfig

getClientSession() → {string}

Gets the client session information.

ClientSession is available during each lifecycle of init. After the connection is destroyed, init needs to be called again to get the latest ClientSession.

Example
const clientSession = TCGSDK.getClientSession();
Returns:
Type
string

start(serverSession) → {void}

Starts cloud rendering.

Example
TCGSDK.start(serverSession);
Parameters:
Name Type Description
serverSession string

The ServerSession returned after the CreateSession API is called.

Returns:
Type
void

destroy(paramsopt) → {void}

Stops cloud rendering immediately.

This API is used to stop the service on the frontend, i.e., to clear the current connection (peerConnection). The cloud will release resources automatically after detecting that there are no heartbeats.

To immediately release cloud resources, call the StopGame API for GS, or call the DestroySession API for CAR.

Example
TCGSDK.destroy();
Parameters:
Name Type Attributes Description
params Object <optional>
Properties
Name Type Attributes Default Description
code number <optional>
0
message string <optional>
''
Returns:
Type
void

reconnect() → {void}

Reconnects to the service. You can set the _init reconnect_ parameter to make the SDK automatically call this API. You can also actively call this API based on the callback code of onDisconnect and your actual business scenario.

Rule: Attempts every 5 seconds, maximum 5 times

Example
TCGSDK.reconnect();
Returns:
Type
void

getIsMobileGame() → {boolean}

Queries whether the current solution is a mobile game solution.

Example
TCGSDK.getIsMobileGame();
Returns:
Type
boolean

reshapeWindow() → {void}

Adjusts the video position.

The entire view will be displayed at the aspect ratio of the cloud resolution, with the short side fully displayed and the long side scaled proportionally. If the display is not as expected, you can call this API to adjust the view or use the CSS style to directly hack the view.

Example
TCGSDK.reshapeWindow();
Returns:
Type
void

setPageBackground(url) → {void}

Sets the background image of the cloud rendering page.

Note that the background image set here is for the frontend container but not the cloud. The cloud background is set through createSession interface.

Parameters:
Name Type Description
url string

The background image.

Returns:
Type
void

setFullscreen(fullscreen, element) → {void}

Sets whether to enable the full screen mode.

Example
TCGSDK.setFullscreen(true, html);
Parameters:
Name Type Description
fullscreen boolean

Whether the full screen mode is enabled.

element HTMLElement

The node to be manipulated.

Returns:
Type
void

getFullscreen() → {boolean}

Queries whether the full screen mode is enabled.

Returns:
Type
boolean

getPageOrientation() → {'portrait'|'landscape'}

Queries page orientation.

Returns:
Type
'portrait' | 'landscape'

getRequestId() → {string}

** Available after calling TCGSDK.start() **

Returns:
Type
string

gameRestart(callbackopt) → {void}

Restarts the currently running game process.

Parameters:
Name Type Attributes Description
callback function <optional>
Returns:
Type
void

gamePause(callbackopt) → {void}

Pauses the currently running game process.

Parameters:
Name Type Attributes Description
callback function <optional>
Returns:
Type
void

gameResume(callbackopt) → {void}

Resumes the currently running game process.

Parameters:
Name Type Attributes Description
callback function <optional>
Returns:
Type
void

sendText(content) → {void}

Quickly sends content when the input box is focused.

Example
TCGSDK.sendText('abc');
Parameters:
Name Type Description
content string

The content to be sent.

Returns:
Type
void

setClientInteractMode(mode) → {void}

Sets the interaction mode of the cloud application, which can also be set through InitConfig clientInteractMode.

Example
TCGSDK.setClientInteractMode('cursor');
Parameters:
Name Type Default Description
mode string 'cursor'

Valid values: 'cursor': Mouse input; 'touch': Touch input.This feature requires support by the cloud application.

Returns:
Type
void

(async) setRemoteDesktopResolution(param) → {Promise.<{code: (0|1)}>}

Sets the resolution width and height of the cloud desktop.

We recommend you call this API in onConnectSuccess.

Cloud applications can be roughly divided into the following four modes

  1. Window with borders - the application has a border, similar to a folder browser window, you can see the desktop while opening the application
  2. Window without borders - the application has no borders, the application resolution is smaller than the desktop resolution, and the status bar such as the title bar cannot be seen. When the application is opened, the desktop can be seen at the same time
  3. Fullscreen without borders - the application has no borders and the application resolution is equal to the desktop resolution, and the desktop is completely blocked by the application.
  4. Exclusive fullscreen - the application exclusively occupies the fullscreen, and the display resolution is controlled by the application. At this time, forcibly modifying the desktop resolution may cause the application to crash

How to distinguish Fullscreen without borders and Exclusive fullscreen?

Pressing alt-tab to switch windows of a Fullscreen without borders application will not cause the display to flicker, and an Exclusive fullscreen application will have a flickering phenomenon

All the above four modes can use this interface except 4 (Exclusive fullscreen) mode

Example
TCGSDK.setRemoteDesktopResolution({width: 1920, height: 1080});
Parameters:
Name Type Description
param Object
Properties
Name Type Description
width number

The cloud desktop width.

height number

The cloud desktop height.

Returns:

The Promise object. Valid values: 0 (success), 1 (failure).

Type
Promise.<{code: (0|1)}>

getRemoteStreamResolution() → {Object}

Gets the resolution of the specified video stream.

Example
const {width, height} = TCGSDK.getRemoteStreamResolution();
Returns:

Object {width: number; height: number}

Type
Object

(async) createCustomDataChannel(param)

Creates a custom dataChannel. We recommend you use this API in the onConnectSuccess callback. Specific request parameters are as follows:

We recommend you call this API in onConnectSuccess.

FAQs

  • The dataChannel has been created, web sends data successfully, but can not receive data back from the cloud application.

    1. The dataChannel has been created,but maybe the cloud application isn't fully launched at this point. Web can send customized data via timeout/interval/polling etc, ensure that cloud application receives the customized data sent by the web properly after lunched successfully. As long as the dataChannel has been created successfully, the data can be sent successfully.
    2. If you receive cloud application data in the onMessage callback, you can unpoll and send the data normally.
  • Types of data that can be sent and received

    The interface supports String and ArrayBuffer

  • Is there a limit to the packet transmission size?

    The service has no limitation on the size of the packet for transmission, but the maximum packet length of UDP is 64KB, and it is recommended that the packet size should be less than MTU 1500. If the packet is too large, it is recommended that it be transmitted in the form of a sub-packet.

Example
let timer = null;

const { sendMessage, code } = await TCGSDK.createCustomDataChannel({
  destPort: 10005,
  onMessage: (res) => {
    console.log('CustomDataChannel onMessage', res);

    // If you receive cloud application data in the onMessage callback, you can unpoll and send the data normally.
    // clearInterval(timer)
  },
});

// The code of 0 means that the dataChannel has been created. but maybe the cloud application isn't fully launched at this point. Web can send customized data via timeout/interval/polling etc, ensure that cloud application receives the customized data sent by the we properly after lunched successfully.
if (code === 0) {
  // Send a customized message
  sendMessage('abc123');

  // timer = setInterval(() => {
  //   sendMessage('abc123');
  // }, 5000);
}

if (code === 1) {
  // Recreate the data channel
}
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Default Description
destPort number

The target port, the recommended port range is 10000-20000.

protocol string <optional>
'text'

'text' | 'binary', for data type from server (response from onMessage)

onMessage function

The callback function for message receipt by dataChannel.

Returns:

Promise object.

Name Type Description
code number 0: Success; 1: Failed to create the ack data channel. Try again. 2: The data channel already exists.
msg string The callback function for message receipt by dataChannel.
sendMessage (message: string | Blob | ArrayBuffer | ArrayBufferView) => void; The method for sending messages, which will pass through data to the data channel of peerConnection. The message parameter supports all data types of RTCDataChannel.

sendKeyboardEvent(param) → {void}

Sends a keyboard event. This method is usually called twice as a key is pressed (down) and released (up) for each keystroke.

For the keycodes, see JavaScript Key Code Event Tool & List.

The common keycodes for the mobile game solution of TCGSDK KEY_BACK = 158 KEY_MENU = 139 KEY_HOME = 172

Example
// keydown
TCGSDK.sendKeyboardEvent({key: 32, down: true});
// keyup
TCGSDK.sendKeyboardEvent({key: 32, down:  false});
Parameters:
Name Type Description
param Object
Properties
Name Type Description
key number

keycode.

down boolean

Whether the key is pressed.

Returns:
Type
void

sendMouseEvent(param) → {void}

Sends a mouse event.

Example
// mouseleft down
TCGSDK.sendMouseEvent({type: 'mouseleft', down: true});
// mouseleft up
TCGSDK.sendMouseEvent({type: 'mouseleft', down: false});
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
type MouseEvent

The mouse event type. Valid values: 'mousedeltamove', 'mousemove', 'mouseleft', 'mouseright', 'mousescroll'.

down boolean

Whether the mouse button is pressed (down) or released (up).

delta boolean <optional>

mouse scroll,values between 1 and -1

Returns:
Type
void

sendGamepadEvent(param) → {void}

Sends a gamepad event.

For the PC (if the browser supports the Gamepad API), TCGSDK has automatically listened and handled the event.

Example
// gamepadconnect
TCGSDK.sendGamepadEvent({ type: 'gamepadconnect' });
// gamepaddisconnect
TCGSDK.sendGamepadEvent({ type: 'gamepaddisconnect' });
// Send key for X
TCGSDK.sendGamepadEvent({ type: 'gamepadkey', key: '0x4000', down: true });
// lt
TCGSDK.sendGamepadEvent({ type: 'lt', x:  200, down: true });
// axisleft
TCGSDK.sendGamepadEvent({ type: 'axisleft', x: 10000, y: -10000 });
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
type GamePadEvent

GamePadEvent 'gamepadconnect' | 'gamepaddisconnect' | 'gamepadkey' | 'axisleft' | 'axisright' | 'lt' | 'rt'

down boolean <optional>

Whether the button is pressed (down) or released (up).

key number <optional>

Gamepad key values

• D-pad values: up: 0x01, down: 0x02 left: 0x04, right: 0x08

• X: 0x4000, Y: 0x8000, A: 0x1000, B: 0x2000

• select: 0x20

• start: 0x10

x number <optional>

Using in lt/rt value: [0-255] or axisleft/axisright value: [-32767~32767]

y number <optional>

Using in axisleft/axisright value: [-32767~32767]

Returns:
Type
void

sendRawEvent(params) → {void}

Deprecated:
  • Yes

Sends mouse and keyboard events (underlying implementation).

Parameters:
Name Type Description
params RawEventData

The underlying raw data type, which can be used to send mouse, keyboard, and joystick messages.

Returns:
Type
void

sendSeqRawEvents(params) → {void}

Deprecated:
  • Yes

Sends the key sequence (underlying implementation).

Parameters:
Name Type Description
params Array.<RawEventData>

The serialized data to be sent.

Returns:
Type
void

setMoveSensitivity(value) → {void}

Sets the cursor sensitivity.

Parameters:
Name Type Description
value number

Value range: A floating point number in the range of [0.01,100.0]

Returns:
Type
void

getMoveSensitivity() → {number}

Gets the current cursor sensitivity value.

Returns:
Type
number

mouseMove(identifier, type, x, y) → {void}

Example
TCGSDK.mouseMove(id: 1, type: 'touchstart', pageX: 100, pageY: 100);
Parameters:
Name Type Description
identifier number

The touch identifier, which must be unique for each touch point in case of multi-touch. The touch identifier of all events of the same touch point must be the same.

type TouchType

The touch event type. Valid values: touchstart, touchmove, touchend, touchcancel. For the same touch point, touchstart must and can correspond to only one touchend or touchcancel.

x number

The X coordinate of the touch point, which should be a number. However, if a floating point number is passed in, it will be processed as a logical coordinate.

y number

The Y coordinate of the touch point, which should be a number. However, if a floating point number is passed in, it will be processed as a logical coordinate.

Returns:
Type
void

mouseTabletMode(param) → {void}

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.

Parameters:
Name Type Description
param boolean

Valid values; true (enable), false (disable).

Returns:
Type
void

setRemoteCursor(mode) → {void}

Parameters:
Name Type Description
mode number

Currently, three cursor modes are supported:

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.

Returns:
Type
void

setCursorState(status) → {void}

Setting the mouse status.

Used to force show/force lock/auto-follow cloud apps to display or lock the mouse

Parameters:
Name Type Description
status string

Three states are currently supported

status='forceShow'

status='forceLock'

status='auto' Automatically follow the cloud application's mouse state, e.g. if the cloud application shows the mouse, the web page shows the mouse, if the cloud application hides the mouse, the web page locks the mouse.

Returns:
Type
void

setCursorShowStat(show) → {void}

Sets whether to hide/show the cursor. However, the cursor hide/show setting distributed from the cloud may overwrite this setting.

Parameters:
Name Type Description
show boolean
Returns:
Type
void

getCursorShowStat() → {boolean}

Gets the cursor hide/show status. Valid values: true, false.

Returns:
Type
boolean

setMouseCanLock(param) → {void}

Sets whether to allow the cursor to be locked.

Parameters:
Name Type Default Description
param boolean true

Valid values: true (yes), false (no). Default value: true.

Returns:
Type
void

lockMouse(param) → {void}

Force Mouse Lock

Parameters:
Name Type Default Description
param boolean true

Valid values: true (yes), false (no). Default value: true.

Returns:
Type
void

setMobileCursorScale(value) → {void}

Parameters:
Name Type Description
value number

The zooming factor, which is 1.0 by default and is the same as that in the cloud. Value range: [0.1,10].

Returns:
Type
void

setRemoteCursorStyle(style) → {void}

Sets the style string. Valid values:

Parameters:
Name Type Description
style 'standard' | 'default_huge'

standard: System default cursor style, which is smaller. default_huge: System large cursor style, which is larger.

Returns:
Type
void

clearRemoteKeys() → {void}

Resets the status of all cloud keys, which is used in scenarios where cloud keys become stuck.

Returns:
Type
void

resetRemoteCapsLock() → {void}

Resets the cloud capsLock to lowercase.

Returns:
Type
void

setDefaultCursorImage(url) → {void}

Sets the default image of the cursor on the cloud rendering page.

Parameters:
Name Type Description
url string

The cursor image.

Returns:
Type
void

setKMStatus(param) → {object}

Sets whether the mouse/keyboard is available. On PC, mouse/keyboard events will be captured by the SDK and sent to the cloud by default.

Example
TCGSDK.setKMStatus({keyboard: false, mouse: false});
Parameters:
Name Type Description
param Object
Properties
Name Type Description
keyboard boolean

Whether the keyboard is available.

mouse boolean

Whether the mouse is available.

Returns:
Type
object

setPaste(enable) → {void}

Sets 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.

Parameters:
Name Type Description
enable boolean
Returns:
Type
void

setStreamProfile(profile, callbackopt) → {void}

Deprecated:
  • Yes

Sets bitrate and stream parameters. This API is used to set the recommended parameters, which may be dynamically adjusted in the cloud based on the game conditions.

Example
TCGSDK.setStreamProfile({ fps: 60, max_bitrate: 8, min_bitrate: 5 });
Parameters:
Name Type Attributes Description
profile Object

Currently available parameters include:

Properties
Name Type Description
fps number

The frame rate in fps. Value range: [10,60].

max_bitrate number

The maximum bitrate in Mbps. Value range: [1,15].

min_bitrate number

The minimum bitrate in Mbps. Value range: [1,15].

callback function <optional>

The settings result callback function, which can be null.

Returns:
Type
void

getDisplayRect()

Gets the parameters of the display area, such as margin, width, and height. Its parameters include:

Returns:

video data obtained through getBoundingClientRect.

Name Type Description
left number The value of the left margin between the view window and the display area.
top number The value of the top margin between the view window and the display area.
width number The playback element (video) width.
height number The playback element (video) height.
pixelRatio number window.devicePixelRatio: The ratio of the current display device pixel resolution.

setVideoVolume(value) → {void}

Sets the video volume level.

Example
TCGSDK.setVideoVolume(0);
Parameters:
Name Type Description
value number

number [0-1]

Returns:
Type
void

getVideoVolume() → {number}

Gets the video volume level.

Returns:
Type
number

playVideo(status) → {void}

Plays back the video.

Example
TCGSDK.playVideo('play');
Parameters:
Name Type Description
status 'play' | 'pause'
Returns:
Type
void

getUserMedia() → {MediaStream}

Gets the user media stream.

Returns:
Type
MediaStream

switchMic(param) → {Promise.<Object>}

Turns on/off the mic.

Example
TCGSDK.switchMic({status: 'open'});
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
status 'open' | 'close'

The on/off status.

profile boolean | MicProfileConstraints <optional>

mic profile

Returns:
Response Type Description
code 0 or 1 0 success 1 failed
msg string message
userMedia MediaStream mic media stream
Type
Promise.<Object>

switchCamera(param) → {Promise.<Object>}

Turns on/off the camera.

Example
TCGSDK.switchCamera({status: 'open'});
TCGSDK.switchCamera({status: 'close'});
// Open 'environment' camera in mobile devices.
TCGSDK.switchCamera({ status: 'open', profile: { deviceId: 'environment' } });
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
status 'open' | 'close'

The on/off status.

profile boolean | CameraProfileConstraints | CameraProfileType <optional>

Camera profile.

Returns:
Response Type Description
code 0 or 1 0 success 1 failed
msg string message
userMedia MediaStream camera media stream
Type
Promise.<Object>

(async) setMicProfile(profile) → {Promise.<Object>}

Sets the mic capturing quality.

Example
TCGSDK.setMicProfile({sampleRate: 44100, echoCancellation: true, noiseSuppression: true, autoGainControl: true});
Parameters:
Name Type Description
profile MicProfileConstraints

MicProfileConstraints is an Object, which contains the following parameters:

Properties
Name Type Attributes Default Description
sampleRate number <optional>
44100

The sample rate. Default value: 44100.

echoCancellation ConstrainBoolean <optional>
true

Whether to enable echo cancellation. Default value: true.

noiseSuppression ConstrainBoolean <optional>
true

Whether to enable noise suppression. Default value: true.

autoGainControl ConstrainBoolean <optional>
true

Whether to enable automatic gain control. Default value: true.

deviceId string <optional>

The ID of the input device, which can be obtained through the getDevices API. The device selected by the system is used by default.

Returns:
Response Type Description
code 0 or 1 0 success 1 failed
msg string message
userMedia MediaStream mic media stream
Type
Promise.<Object>

(async) setCameraProfile(profile) → {Promise.<Object>}

Sets the camera capturing quality.

Example
// Set the resolution
TCGSDK.setCameraProfile('720p');
// Custom settings
TCGSDK.setCameraProfile({width: '1920', height: '1080', frameRate: '60', bitrate: 2000});
// Switch camera in mobile
TCGSDK.setCameraProfile({ deviceId: 'environment' });
TCGSDK.setCameraProfile({ deviceId: 'user' });
Parameters:
Name Type Description
profile CameraProfileType | CameraProfileConstraints

CameraProfileType = "120p" | "180p" | "240p" | "360p" | "480p" | "720p" | "1080p"

CameraProfileConstraints is an Object, which contains the following parameters:

Properties
Name Type Attributes Default Description
width number <optional>
1280

The width. Default value: 1280.

height number <optional>
720

The height. Default value: 720.

frameRate number <optional>
30

The frame rate. Default value: 30.

bitrate number <optional>
1500

The bitrate in Kbps. Default value: 1500.

deviceId string <optional>

The ID of the input device, which can be obtained through the getDevices API. The device selected by the system is used by default. Mobile can pass 'user' | 'environment', to use front/rear camera.

Returns:
Response Type Description
code 0 or 1 0 success 1 failed
msg string message
userMedia MediaStream camera media stream
Type
Promise.<Object>

getDevices() → {Array.<MediaDeviceInfo>}

Gets all devices.

Returns:
Type
Array.<MediaDeviceInfo>

setVideoOrientation(param) → {void}

Sets the video rotation angle.

-We recommend you do not implement screen rotation out of the SDK, as screen rotation involves complex coordinate conversion, which is already implemented in the SDK. The SDK also implements plugin rotation and data processing internally. Therefore, we recommend you use this method or directly configure automatic rotation in the Init parameter.-

Example
// Rotate an HTML view
TCGSDK.setVideoOrientation({ deg: 90, rotateContainer: true });
// Rotate `MountPoint`
TCGSDK.setVideoOrientation({ deg: 90, rotateMountPoint: true });
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Default Description
deg 0 | 90 | 270 0

Currently, 0 and 270 degrees are supported for mobile games, and 0 and 90 degrees are supported for other applications.

rotateContainer boolean <optional>
true

Whether to rotate the entire HTML view. Default value: true.

rotateMountPoint boolean <optional>
false

Whether to rotate the mountPoint node. Default value: false.

Returns:
Type
void

getPageSize() → {Object}

Gets the page size.

Example
const {width, height} = TCGSDK.getPageSize();
Returns:

{ width: number; height: number };

Type
Object

setDebugMode(param) → {void}

Enables/Disables the debugging mode. If it is enabled, logs will be printed in the console. It can also be set through the Init parameter.

Example
TCGSDK.setDebugMode({showLog: true, showStats: true});
Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
showLog boolean <optional>

Whether to print all logs of the SDK.

showStats boolean <optional>

Whether to display the WebRTC status on the data panel. You can also press CTRL + ~ to display it.

showSendKmData boolean <optional>

Whether to print the messages input by the keyboard/mouse.

showSendAckData boolean <optional>

Whether to print the sent ACK messages.

showSendHbData boolean <optional>

Whether to print the sent heartbeat messages.

showOnHbMessage boolean <optional>

Whether to print the heartbeat response packet messages.

showOnKmMessage boolean <optional>

Whether to print the keyboard/mouse response messages.

showOnAckMessage boolean <optional>

Whether to print the ACK response packet messages.

showOnCdMessage boolean <optional>

Whether to print the CD response packet messages.

showOnSvMessage boolean <optional>

Whether to print the server response packet messages.

Returns:
Type
void

reportLog() → {Object}

Reports logs.

Returns:

{ code: number; message: string } code=0 success code=-1 failed

Type
Object

setLogHandler(handler) → {void}

Sets the log callback function to facilitate external access to detailed logs. The purpose of this API is the same as the onLog callback passed in during init.

Parameters:
Name Type Description
handler function
Returns:
Type
void

toggleMetricReportBulk(start) → {void}

Sets whether to report performance logs.

Parameters:
Name Type Description
start boolean
Returns:
Type
void

getPlayerVolume(id) → {number}

Multi-player cloud game

Gets the volume level of the specified player.

Parameters:
Name Type Description
id string

用户id

Returns:
Type
number

setPlayerVolume(id, val) → {number}

Multi-player cloud game

Sets the volume level of the specified player.

Parameters:
Name Type Description
id string

用户id

val number

音量 [0-1]

Returns:
Type
number

getSeats() → {Promise.<SeatsInfo>}

Multi-player cloud game

Gets all seats.

Returns:

返回 Promise 对象。

Type
Promise.<SeatsInfo>

submitSeatChange(param) → {Promise.<{code: number}>}

Multi-player cloud game

Applies for switching the role or seat (by a guest). The response codes are as detailed below:

Parameters:
Name Type Description
param Object
Properties
Name Type Description
user_id string

The user ID.

to_role 'viewer' | 'player'

The role to be switched to.

seat_index number

The seat number.

Returns:

The response codes are as detailed below:

Code Description
0 Success
1001 MultiPlayerInvalidSeatIndex
1002 MultiPlayerNoAuthorized
1003 MultiPlayerNoSuchRole
1004 MultiPlayerNoSuchUser
1005 MultiPlayerAssignSeatFailed
1006 MultiPlayerJsonParseFailed
1007 MultiPlayerIgnoredHostSubmit
Type
Promise.<{code: number}>

seatChange(param) → {Promise.<{code: number}>}

Multi-player cloud game

Only the host player can call this API. The response codes are as detailed below:

Parameters:
Name Type Description
param Object
Properties
Name Type Description
user_id string

The user ID.

to_role 'viewer' | 'player'

The role to be switched to.

seat_index number

The seat number.

Returns:

The response codes are as detailed below:

Code Description
0 Success
1001 MultiPlayerInvalidSeatIndex
1002 MultiPlayerNoAuthorized
1003 MultiPlayerNoSuchRole
1004 MultiPlayerNoSuchUser
1005 MultiPlayerAssignSeatFailed
1006 MultiPlayerJsonParseFailed
1007 MultiPlayerIgnoredHostSubmit
Type
Promise.<{code: number}>

changeMicStatus(param) → {Promise.<ChangeMicStatusResponse>}

Multi-player cloud game

Switches the mic status.

Parameters:
Name Type Description
param Object
Properties
Name Type Description
status string

1: Actively mute the mic. 2: Unmute the mic.

user_id string

The user ID

Returns:

ChangeMicStatusResponse, which has the following types:

Response Type Description
type string mic_status (0 ==> Success ; -2 ==> NoAuthorized ; -4 ==> NoSuchUser)
code number 0 ==> The mic is muted by the admin; 1 ==> The mic is muted by the user actively; 2 ==> The mic is unmuted
status number status (optional)
user_id string user_id (optional)
Type
Promise.<ChangeMicStatusResponse>