更新时间:2023-03-23 GMT+08:00
场景2:登录
描述
可用华为云会议帐号或App ID或登录华为云会议。创建会议等接口不支持在未登录状态下调用,若要使用完整的会议功能,必须先登录华为云会议。
![](https://support.huaweicloud.com/intl/zh-cn/sdkreference-meeting/public_sys-resources/note_3.0-zh-cn.png)
在未登录状态下,只能加入已经创建的会议。
业务流程
使用SDK登录时,先调用Login接口,然后处理回调函数OnLoginResult。
- 接口调用
- 组装数据结构HwmLoginInfo。
- 选择合适的登录类型。
- 根据登录类型给对应的变量赋值。
- 调用Login进行登录,第1步中的数据作为参数。
- 组装数据结构HwmLoginInfo。
- 处理回调函数
处理回调函数OnLoginResult。
示例代码
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 |
/** * 登录处理 */ int demoLoginDlg::Login() { int ret; //设置App ID登录参数 string userId= "admin@1"; string userName= "Mike"; string email= "xxx@xxx.com"; string phoneNumber= "1234567890"; /** *.此处省略第三方服务器做的数据转换,最后获取到nonce和signature */ 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时间,单位s loginParam.authType = hwmsdkagent::HWM_AUTH_TYPE_APPID; //调用登录接口 ret = hwmsdkagent::Login(&loginParam); return ret; } |
1 2 3 4 5 6 7 8 9 10 11 |
/** * 登录接口回调 */ 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); } |
父主题: 典型场景