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

Scenario 2: Login

Description

You can log in to the Huawei Cloud Meeting server using your Huawei Cloud Meeting account or app ID. The API for creating a meeting can be called only when you have logged in. To use complete meeting functions, log in to Huawei Cloud Meeting.

If you have not logged in, you can join only the meetings that have been created.

Service Process

When using the SDK for login, call the Login API, and then implement the OnLoginResult function.

  1. Call the API.

    1. Assemble the HwmLoginInfo data structure.
      1. Select a proper login type.
      2. Assign a value to the corresponding variable based on the login type.
    2. Call the Login API to log in. The data in the preceding step is used as input parameters.

  2. Implement the callback function.

    Implement the OnLoginResult 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
/**
* Login
*/
int demoLoginDlg::Login()
{
    int ret;
    // Set app ID login parameters.
    string userId= "admin@1";
    string userName= "Mike";
    string email= "xxx@xxx.com";
    string phoneNumber= "1234567890";
   /**
    *. The data conversion performed by the third-party server is omitted here. The nonce and signature are obtained.
    */
    strncpy_s(loginParam.appIdAuthInfo.thirdUserId, userId.c_str(), HWM_MAX_USER_ID_LEN);
    strncpy_s(loginParam.appIdAuthInfo.userName, userName.c_str(), HWM_MAX_USER_NAME_LEN);
    strncpy_s(loginParam.appIdAuthInfo.signature, signature.c_str(), HWM_MAX_SIGNATURE_LEN);
    strncpy_s(loginParam.appIdAuthInfo.nonce, nonce.c_str(), HWM_APPID_NONCE_LEN );
    strncpy_s(loginParam.appIdAuthInfo.email, email.c_str(), HWM_MAX_EMAIL_LEN);
    strncpy_s(loginParam.appIdAuthInfo.phoneNumber, phoneNumber.c_str(), HWM_MAX_PHONE_NUM_LEN);
    loginParam.appIdAuthInfo.expireTime = 1598398920; // UTC time, in seconds

    loginParam.authType = hwmsdkagent::HWM_AUTH_TYPE_APPID;
    // Call the login API.
    ret = hwmsdkagent::Login(&loginParam);

    return ret;
}

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