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

Inviting a Participant

AddAttendee

API Description

This API is used to add participants to a meeting or call.

Precautions

  1. If this API is called when you are not in a meeting or call, a failure message is returned.
  2. If this API is called during a call, the call is converted into a meeting.
  3. This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.

Method Definition

1
HWM_SDK_AGENT_API hwmsdk::HwmErrCode AddAttendee(HwmConfAttendee *attendees, unsigned int count);

Callback Function

1
virtual void OnAddAttendeeResult(hwmsdk::HwmErrCode ret, const char* reason) {};

Parameter Description

Table 1 HwmConfAttendee parameters

Parameter

Mandatory

Type

Description

name

Yes

char[]

Participant name.

number

Yes

char[]

Number. If this parameter is set to the SIP number (for example, +99111244216210249) allocated to the account, the Huawei Cloud Meeting app is called. If this parameter is set to a PSTN number (for example, 18700000000), the number is called through the VoIP gateway if the enterprise has enabled PSTN call. This parameter is used for account and password authentication. Either this parameter or thirdUserId must be set.

thirdUserId

Yes

char[]

Third-party user ID. This parameter is used for app ID authentication. Either this parameter or number must be set.

accountId

No

char[]

Huawei Cloud Meeting account.

Return Values

Table 2 Return values

Type

Description

HwmErrCode

If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes.

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 a participant.
*/
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;
}