CloudHub Docs
Download Documents


Fast integration SDK


Run the installation command:

npm install cloudhub-electron-sdk  --save


1. Get the SDK

// es6:
import RtcEngine from 'cloudhub-electron-sdk';

// commonjs:
const RtcEngine = require('cloudhub-electron-sdk').default

const rtcEngine =  RtcEngine || {};

2. initialization

// rtcEngine.enableVideo();If you call enableVideo before joining the channel, the video module will be automatically enabled

See initialize for details

3. Join the channel

rtcEngine.joinChannel('', channelId, {}, '');

See join Channel for details

4. Publish local audio and video after joining the channel

rtcEngine.on('onJoinChannel', data => {

5. Subscribe to remote users

const videoContainerEle = document.getElementById('videoContainer');

rtcEngine.on('onRemoteVideoStateChanged', data => {
   const { state, uid, reason, streamId } = data;
   const videoId = `${streamId}-player`;
   let videoEle = document.getElementById(videoId);
   // Remote stream removal
   // Remove the remote stream if the playback element exists
   if (state === 0) {
      if (videoEle) {
         rtcEngine.removeRemoteVideo(uid, streamId);
   // Remote stream addition
   // If the playback element does not exist, start to create the playback element and play the remote video
   if (state === 1) {
      if (!videoEle) {
         videoEle = document.createElement('div') = videoId;
         rtcEngine.setupRemoteVideo(uid, streamId, videoEle);

6. Leave channel


See leave Channel for details

other instructions

If a 64-bit system is packed with a 32-bit electron

1.Add the configuration item cloudhub_electron_arch in the root directory

If cloudhub_electron_arch is not configured, follow the system version
If configured, the corresponding addon will be downloaded

   "name": "cloudhub-electron-sdk-demo",
   "dependencies": {
      "cloudhub-electron-sdk": "^3.3.9",
   "devDependencies": {
      "electron": "^10.1.3",
   "cloudhub_electron_arch": "ia32"

2.Install 32-bit electron

The installed 32-bit electron version must be consistent with the electron version configured in package.json

npm i electron@10.1.3 --arch=ia32