Guide

For specific use cases, please refer to the corresponding demo

Step 1 Page preparation

initialization script in the page.

import SDK

<script src="path/to/sdk" charset="utf-8"></script>

OR

import TCGSDK from 'path-to-TCGSDK';

Step 2 Initialize the SDK

TCGSDK.init({
  appid: 1234567,
  mount: 'mount-point', // The nodes that need to be loaded into the cloud rendering view.
  debugSetting: {
    showLog: true,
  },
  onConnectSuccess: (res) => {
    console.log('onConnectSuccess', res);
  },
  onDisconnect: (res) => {
    console.log('onDisconnect', res);
  },
  onInitSuccess: async (res) => {
    console.log('%c onInitSuccess', 'color: red', res);

    // Get ServerSession from cloud API.
    await StartGame();
  }
});

Step 3 Rendering

TCGSDK.start(ServerSession);

Step 4 Destroy

TCGSDK.destroy(); // Web side close, CLoud will wait for the heartbeat timeout and start recycling and releasing resources

OR Use Tencent cloud API to DestroySession