更新时间:2023-03-23 GMT+08:00

场景6:创建会议

描述

在使用华为云会议帐号登录后,可以调用创建会议接口创建立即会议。创建会议时可以携带与会人信息,也可以不携带。

业务流程

若要创建个人会议ID的会议或者云会议室的会议,则需要先调用getVmrList接口查询个人会议ID和云会议室信息,然后处理回调函数onGetVmrListResult返回的数据,该数据可用于创建会议。

使用SDK创建立即会议时,先调用createConf接口,然后处理接口回调函数onCreateConfResult和订阅的消息通知onConfStateChanged、onConfInfoNotify。

  1. 接口调用

    1. 组装数据结构CreateConfInfo(包含结构内Array<AttendeeBaseInfo>,可不带)和接口回调函数onCreateConfResult。
    2. 调用createConf接口开始创建,第1步中的数据作为参数。

  2. 处理回调函数

    处理回调函数onCreateConfResult。

  3. 处理消息通知

    处理消息通知onConfStateChanged。

  4. 处理消息通知

    处理消息通知onConfInfoNotify。

  5. 处理消息通知

    处理消息通知onConfListChanged。

示例代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
/**
* 创建会议
*/
async goToCreateConf() {
    let param = {
        subject: "我的会议",
        mediaType: mediaType: MediaType.HWM_MEDIA_TYPE_VIDEO,
        needPassword: true,
        confAllowJoinUser: ConfAllowJoinUserType.CONF_ALLOW_JOIN_ANYONE,
        isMicOn: true, // 进入会议后默认麦克风开启
        isCameraOn: false, // 进入会议后默认摄像头关闭
    }
    const apiService = new ApiService();
    let setResult = await apiService.createConf(param);
    if (setResult.ret != 0) {
        window.electron.ipcRenderer.send("show-error-alert", "createConf error = " + setResult.ret);
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
/**
* ApiService中createConf接口定义
*/
async createConf(createConfInfo) {
  return new Promise((resolve) => {
    let resultCallback = (ret, reason, createConfResult) => {
      console.log("createConf, out data = ", { ret, reason, createConfResult });
      resolve({ ret, reason, createConfResult });
    };
    console.log("createConf, in param = ", createConfInfo);
    this.uisdkService.getConfCtrlApi().createConf(createConfInfo, resultCallback);
  });
}

Electron SDK接口中的字符串参数,比如会议主题、与会人姓名等,需要编码成UTF8,否则接口会报错。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**
* 订阅会议状态消息onConfStateChanged通知
*/
uisdkService.getConfCtrlApi().setOnConfStateChangedCB(NotifyService.handleOnConfStateChanged);

/**
* NotifyService中handleOnConfStateChanged定义
*/
static handleOnConfStateChanged(confStateInfo) {
    console.log('OnConfStateChanged', ', confStateInfo = ', confStateInfo);
}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**
* 订阅会议信息消息onConfInfoNotify通知
*/
uisdkService.getConfCtrlApi().setOnConfInfoNotifyCB(NotifyService.handleOnConfInfoNotify);

/**
* NotifyService中handleOnConfInfoNotify定义
*/
static handleOnConfInfoNotify(confInfo) {
    console.log('OnConfInfoNotify', ', confInfo = ', confInfo);
}

onConfListChanged事件通知跟预约会议场景相同,请参考预约会议的示例代码

Electron SDK回调函数或者消息通知中的字符串都是UTF8编码的。