Updated on 2023-03-23 GMT+08:00

Getting Started

Before integrating the Electron SDK into a third-party application, familiarize yourself with the basic process of integrating the Huawei Cloud Meeting Electron SDK into an Electron client by referring to Building the Electron Demo.

To integrate Huawei Cloud Meeting Windows SDK into a third-party Electron client, perform the following steps:

  1. Download the Electron SDK.
  2. Decompress the Electron SDK to obtain the following directories and files.

    Figure 1 Directory structure of the SDK package

  3. Copy Electron SDK files.

    1. If Node.js has been installed, run the following command to check whether the Node.js version is 32-bit or 64-bit. The result x64 indicates 64-bit and ia32 indicates 32-bit.

    $ node -p "process.arch"

    2. If Node.js is not installed, download the required version from the Node.js website.

    • If the platform is Windows and the Node.js version is 32-bit, run the run_demo_win32.bat script in the directory generated after decompression in the preceding step.
    • If the platform is Windows and the Node.js version is 64-bit, run the run_demo_x64.bat script in the directory generated after decompression in the preceding step.
    • If the platform is macOS, run the run_demo_mac.sh script in the directory generated after decompression in the preceding step.

    The .bat or .sh script can perform the following operations:

    • Compile TS APIs and generate JS and types files.
    • Copy the SDK files of the corresponding platform to the corresponding directory (sdk/win32, sdk/x64, or sdk/mac).
    • Run the demo.
    • Copy the js and types directories and their subdirectories and files and the package.json file in the root directory to a directory of the project. (If the project uses TypeScript, copy the ts directory and its subdirectories and files.)

      The JavaScript APIs to be called are stored in the js folder, and the entry file is js\index.js. (If the project uses TypeScript, the entry file is ts\index.ts.)

  4. Add dependencies.

    Add dependencies by referring to the package.json file in the demo.

    1
    2
    3
    "dependencies": {
        "electron": "^13.6.7"
    },
    

  5. Use the import mode to reference the directory where API files of the Electron SDK are located, initialize the UISDKService object, and configure the node path to load the SDK.

    Refer to the AppService.js/NotifyService.js code in the demo.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    import UISDKService from '../../../';
    const os = window.require('os');
    const platform = os.platform();
    const arch = os.arch();
    const path = window.require("path");
    
    let instance = null;
    export default class ApiService {
      constructor() {
        if (!instance) {
          instance = this;
          // Pass the actual node path to the UISDKService constructor.
          let _path = (platform == 'darwin' ? './../sdk/mac/' : arch == 'x64' ? './../sdk/x64/' : './../sdk/win32/');
          let nodePath = path.join(window.__dirname, (_path + "HwmUisdk.node"));
          console.log("ApiService nodePath", nodePath);
          this.uisdkService = new UISDKService(nodePath);
        }
        return instance;
      }
    }
    

  6. Call APIs.

    For details about the API calling and message notification processing sequence of Huawei Cloud Meeting, see API Call in Typical Scenarios.

    JavaScript APIs that can be called by third-party applications are stored in js/api/. You can call these APIs by referring to AppService/ApiService.js in the demo.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    import UISDKService from '../../../';
    const os = window.require('os');
    const platform = os.platform();
    const arch = os.arch();
    const path = window.require("path");
    
    let instance = null;
    export default class ApiService {
      constructor() {
        if (!instance) {
          instance = this;
          // Pass the actual node path to the UISDKService constructor.
          let _path = (platform == 'darwin' ? './../sdk/mac/' : arch == 'x64' ? './../sdk/x64/' : './../sdk/win32/');
          let nodePath = path.join(window.__dirname, (_path + "HwmUisdk.node"));
          console.log("ApiService nodePath", nodePath);
          this.uisdkService = new UISDKService(nodePath);
        }
        return instance;
      }
    
      init(initInfo) {
        console.log("init, in param = ", initInfo);
        let ret = this.uisdkService.init(initInfo);
        console.log("init, out data = ", ret);
        return ret;
      }
    }
    

  7. Subscribe to event notifications.

    JavaScript APIs for subscribing to notifications that can be received by the third-party application are stored in js/api/. You can subscribe to these notifications by referring to AppService/NotifyService.js in the demo.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    import UISDKService from '../../../';
    const os = window.require('os');
    const platform = os.platform();
    const arch = os.arch();
    const path = window.require("path");
    
    export default class NotifyService {
        static setNotifyFunc() {
    
            let _path = (platform == 'darwin' ? './../sdk/mac/' : arch == 'x64' ? './../sdk/x64/' : './../sdk/win32/');
            let nodePath = path.join(window.__dirname, (_path + "HwmUisdk.node"));
            console.log("NotifyService nodePath", nodePath);
            let uisdkService = new UISDKService(nodePath);
            uisdkService.getConfMgrApi().setOnConfListChangedCB(NotifyService.handleOnConfListChanged);
        }
    
        static handleOnConfListChanged(confListInfo) {
            console.log('OnConfListChanged', ', confListInfo = ', confListInfo);
            let _confListInfo = window.sessionStorage.getItem("confListInfo");
            _confListInfo = _confListInfo ? JSON.parse(_confListInfo) : [];
            console.log("sessionStorage confList:", _confListInfo);
            let conflistNew = confListInfo.confListItem;
            let _data = JSON.stringify(conflistNew ? conflistNew : []);
            window.sessionStorage.setItem("confListInfo", _data);
        }
    }
    

  8. (Optional) Use enumerations provided by the Electron SDK.

    You can directly use the enumeration definitions provided by the Electron SDK, copy js/Api/enum.js and types/Api/enum.d.ts to a directory of the project, and use the enumeration definitions by referring to src/Constants/typeOption.js in the demo.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    import { MediaType } from "./enum";
    
    export const MediaTypeOptions = [
        {
            value: MediaType.HWM_MEDIA_TYPE_AUDIO,
            label: "Audio",
        },
        {
            value: MediaType.HWM_MEDIA_TYPE_VIDEO,
            label: "Video",
        }
    ];