更新时间:2024-04-22 GMT+08:00
分享

场景6:创建会议

描述

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

业务流程

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

使用SDK创建立即会议时,先调用CreateConf接口,然后处理回调函数OnCreateConfResult和消息通知OnConfState、OnConfInfo。

  1. 接口调用

    1. 组装数据结构HwmCreateConfInfo。
    2. 组装数据结构HwmConfAttendee。
    3. 调用CreateConf开始创建,第1步中的数据作为参数。

  2. 处理回调函数

    处理回调函数OnCreateConfResult。

  3. 处理消息通知

    处理消息通知OnConfState。

  4. 处理消息通知

    处理消息通知OnConfInfo。

  5. 处理消息通知

    处理消息通知OnConfList。

示例代码

 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* 创建会议
*/
int demoCreateConfWithAttendeeDlg::clickCreatConfWithAttendee()
{
    int ret;
    hwmsdkagent::HwmCreateConfInfo data;
    memset(&data, 0, sizeof(hwmsdkagent::HwmCreateConfInfo));
    
    //设置会议主题
    strncpy_s(data.subject, GetMeetingSubjectStr().c_str(), HWM_MAX_SUBJECT_LEN);
    //设置会议类型
    data.mediaType = hwmsdkagent::HWM_VIDEO_AND_DATA
    //设置会议是否需要来宾密码
    data.needPassword = true;
    data.callInRestriction = hwmsdkagent::RESTRICTION_CALL_IN_ALL;
    //设置vmrId,若创建随机会议,则vmrId为空 此处m_confIdTypeCombo排序是把随机会议放在首位
    //因此vmrIdSelect > 0 为个人会议id与云会议室id场景
    const auto vrmIdSelect = m_confIdTypeCombo.GetCurSel();
    if (vrmIdSelect > 0 && vrmIdSelect - 1 < vmrList.size())
    {
        strcpy_s(data.vmrId, HWM_MAX_VMR_CONF_ID_LEN, vmrList[vrmIdSelect - 1].vmrId);
    }

    
    //设置与会人
    //获取与会人信息,实际使用是根据实际情况获取
    CString tempCString;
    m_attendeesEdit.GetWindowText(tempCString);
    string tempString = CTools::UNICODE2UTF(tempCString);
    vector<string> list = CTools::split(tempString, ';');
    vector<string> temp;
    int count = list.size();
    int realCount = 0;
    if (count > 0)
    {
        //申请结构体内存
        hwmsdkagent::HwmConfAttendee* participants;
        participants = (hwmsdkagent::HwmConfAttendee*)malloc(sizeof(hwmsdkagent::HwmConfAttendee) * count);
        if (participants == NULL)
        {
            return -1;
        }
        memset(participants, 0, sizeof(hwmsdkagent::HwmConfAttendee)*count);
 
        hwmsdkagent::HwmConfAttendee* participantsTemp = participants;
        for (int i = 0; i < count; i++)
        {
            temp = CTools::split(list[i], '-');
            if (temp.size() == 2)
            {
                //name赋值
                strncpy_s(participantsTemp->name, (char *)temp[0].c_str(), HWM_MAX_DISPLAY_NAME_LEN);
                //number赋值
                strncpy_s(participantsTemp->number, (char *)temp[1].c_str(), HWM_MAX_NUMBER_LEN);
                //指针个数加1
                realCount++;
                participantsTemp++;
            }
        }
        //调用SDK接口,创建会议
        ret = hwmsdkagent::CreateConf(&data, participants, realCount);
 
        //释放内存空间
        free(participants);
        participants = NULL;
    }
    else
    {
        //不携带与会人创建会议
        ret = hwmsdkagent::CreateConf(&data, NULL, 0);
    }
    return ret;
}

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**
* 创建会议接口回调
*/
void demoCallbackProc::OnCreateConfResult(hwmsdk::HwmErrCode ret, const char* msg)
{
    CString codeStr;
    codeStr.Format(_T("%d"), ret);
    string msgStr = CTools::UTF82MultiByte(msg);
    CString tips = _T("OnCreateConfResult code:") + codeStr + _T(", msg:") + CString(msgStr.c_str());
    AfxMessageBox(tips);
}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
/**
* 会议状态消息通知
*/
void demoNotifyProc::OnConfState(HwmConfStateInfo *confStateInfo)
{
    CString str;
    str.Format(_T("%d"), confStateInfo->state);
    CString reason;
    reason.Format(_T("%d"), confStateInfo->reason);
    CString tips = _T("OnConfState state:") + str + _T(", reason:")+ reason;
    AfxMessageBox(tips);
 
}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* 会议信息消息通知
*/
void demoNotifyProc::OnConfInfo(HwmConfInfo *confInfo)
{
    string urlStr = CTools::UTF82MultiByte(confInfo->url);
    string confIdStr = CTools::UTF82MultiByte(confInfo->confId);
    string chairmanPwdStr = CTools::UTF82MultiByte(confInfo->chairmanPwd);
    string generalPwdStr = CTools::UTF82MultiByte(confInfo->generalPwd);
    string subjectStr = CTools::UTF82MultiByte(confInfo->subject);
 
    CString role;
    role.Format(_T("%d"), confInfo->role);
 
    CString tips = _T("OnConfInfo confUrl:") + CString(urlStr.c_str())
        + _T(", confId:") + CString(confIdStr.c_str()) + _T(", confRole:") + CString(role) 
        + _T(", chairmanPwd:") + CString(chairmanPwdStr.c_str())
        + _T(", generalPwd:") + CString(generalPwdStr.c_str())
        + _T(", subject:") + CString(subjectStr.c_str());
    AfxMessageBox(tips);
}

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

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

分享:

    相关文档

    相关产品