Updated on 2024-07-30 GMT+08:00

Scenario 9: Adding Participants

Description

You can call the API for adding participants during a meeting.

Service Process

When using the SDK to add participants, call the AddAttendee API, and implement the OnAddAttendeeResult function.

  1. Call the API.

    1. Assemble the HwmConfAttendee data structure.
    2. Call the AddAttendee API to add participants. The data in preceding steps is used as input parameters.

  2. Implement the callback function.

    Implement the OnAddAttendeeResult function.

Sample Code

 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
/**
* Add participants.
*/
int demoAddAttendeeDlg::clickAddAttendee()
{
    int ret;
    CString tempCString;
    
    // Obtain participant details based on site requirements.
    m_numbersEdit.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)
    {
        // Apply for the structure memory.
        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)
            {
                // Assign a value to name.
                strncpy_s(participantsTemp->name, (char *)temp[0].c_str(), HWM_MAX_DISPLAY_NAME_LEN);
                // Assign a value to number.
                strncpy_s(participantsTemp->number, (char *)temp[1].c_str(), HWM_MAX_NUMBER_LEN);
                // Increase the number of pointers by 1.
                realCount++;
                participantsTemp++;
            }
        }
 
        ret = hwmsdkagent::AddAttendee(participants, realCount);
        
        // Release memory space.
        free(participants);
        participants = NULL;
    }
    
    return ret;
}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**
* Callback of the API for adding participants
*/
void demoCallbackProc::OnAddAttendeeResult(hwmsdk::HwmErrCode ret, const char* msg)
{
    CString codeStr;
    codeStr.Format(_T("%d"), ret);
    string msgStr = CTools::UTF82MultiByte(msg);
    CString tips = _T("OnAddAttendeeResult code:") + codeStr + _T(", msg:") + CString(msgStr.c_str());
    AfxMessageBox(tips);
}