Updated on 2024-07-30 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 only join created meetings.

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
/**
* Login
*/
int demoLoginDlg::Login()
{
    int ret;
    // Set app ID login parameters.
   /**
    *. The data conversion performed by the third-party server is omitted here. The nonce and signature are obtained.
    */
    strncpy_s(loginParam.appIdAuthInfo.thirdUserId, GetUserId.c_str(), HWM_MAX_USER_ID_LEN);
    strncpy_s(loginParam.appIdAuthInfo.userName, GetUserName.c_str(), HWM_MAX_USER_NAME_LEN);
    strncpy_s(loginParam.appIdAuthInfo.signature, GetSignature().c_str(), HWM_MAX_SIGNATURE_LEN);
    strncpy_s(loginParam.appIdAuthInfo.nonce, GetNonce().c_str(), HWM_APPID_NONCE_LEN );
    strncpy_s(loginParam.appIdAuthInfo.email, GetEmail.c_str(), HWM_MAX_EMAIL_LEN);
    strncpy_s(loginParam.appIdAuthInfo.phoneNumber, GetPhoneNumber.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);
}