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 Electron SDK into a third-party Electron client, perform the following steps:
- Download the Electron SDK.
- Decompress the Electron SDK to obtain the following directories and files.
Figure 1 Directory structure of the SDK package
1. If the macOS platform is used, decompress the Electron SDK on the macOS computer. Or, the framework will be damaged and the SDK cannot be used.
- Copy Electron SDK files.
1. If Node.js has been installed, run the following command to check the Node.js version. 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.)
- Add dependencies.
Add dependencies by referring to the package.json file in the demo.
1 2 3
"dependencies": { "electron": "^13.6.7" },
- 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 'hwmsdk-electron'; 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; } }
- 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 'hwmsdk-electron'; 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; } }
- 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 'hwmsdk-electron'; 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); } }
- (Optional) Use enumerations provided by the Electron SDK.
You can use the enumeration definitions provided by the Electron SDK for the third-party application, copy packages/hwmsdk-electron/js/Api/enum.js and packages/hwmsdk-electron/types/Api/enum.d.ts to a directory of the project, and use these enumeration definitions by referring to packages/hwmsdk-electron-demo/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", } ];
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot