初始化
更新时间: 2023/06/29 06:46:48
在登录圈组 SDK 前,您需要先将圈组 SDK 进行初始化。
前提条件
引入圈组 SDK
您可使用如下指将圈组 SDK 引入您的本地项目。
#include "nim_qchat_cpp_wrapper/nim_cpp_qchat_api.h" // 引入 QChat 库
初始化圈组 SDK
功能介绍
圈组模块初始化 (SDK初始化时调用一次)。
参数说明
参数 | 类型 | 说明 |
---|---|---|
app_data_path {""} | std::string | APP数据存储路径,如果为空,则使用系统默认路径 |
app_install_path {""} | std::string | APP安装路径,用于加载依赖库,如果为空,则使用当前路径 |
custom_timeout {0} | uint32_t | 自定义通信超时时间,单位秒, 为 0 使用默认值 |
auth_timeout {0} | uint32_t | 自定义鉴权超时时间,单位秒, 为 0 使用默认值 |
database_encrypt_key | std::string | 数据库加密密钥,如果为空,则使用默认值 |
encryption_configuration | QChatEncryptionConfiguration | 加密配置 |
fcs_configuration | QChatFCSConfiguration | FCS配置 |
message_cache_configuration | QChatMessageCacheConfiguration | 消息缓存配置 |
示例代码
cppQChatInitParam param;
// customize param for initializing.
param.app_data_path = "";
param.app_install_path = "";
param.custom_timeout = 0;
param.auth_timeout = 0;
param.database_encrypt_key = "";
// encryption_configuration
param.encryption_configuration.nego_key_neca = kNIMQChatEncryptionAlgorithmRSA;
param.encryption_configuration.comm_neca = kNIMQChatCommEncryptionAlgorithmRC4;
param.encryption_configuration.hand_shake_type = kNIMQChatHandShakeTypeMulti;
param.encryption_configuration.nego_key_neca_key_parta = "";
param.encryption_configuration.nego_key_neca_key_partb = "";
param.encryption_configuration.nego_key_neca_key_version = 0;
// fcs_configuration
param.fcs_configuration.fcs_auth_type = kNIMQChatFCSAuthenticationTypeToken;
param.fcs_configuration.mock_ua = "";
param.fcs_configuration.mock_refer = "";
param.fcs_configuration.auto_download_history_msg_attach_ = true;
param.fcs_configuration.auto_download_audio = true;
param.fcs_configuration.auto_download_video = true;
param.fcs_configuration.auto_download_video_thumb = true;
param.fcs_configuration.auto_download_image = true;
param.fcs_configuration.auto_download_image_thumb = true;
param.fcs_configuration.auto_download_file = true;
param.fcs_configuration.thumbnail_width = 150;
param.fcs_configuration.thumbnail_height = 100;
// message_cache_configuration
param.message_cache_configuration.enable_message_cache = true;
// for more infomation please see the definition of QChatInitParam.
bool result = QChat::Init(param);
if (!result) {
// error handling
return;
}
卸载圈组 SDK
功能介绍
圈组 SDK 卸载 (SDK 卸载时调用一次)。
示例代码
cppQChatCleanupParam param;
// customize param for cleaning up.
// ...
// for more infomation please see the definition of QChatCleanupParam.
bool result = QChat::Cleanup(param);
if (!result) {
// error handling
return;
}
此文档是否对你有帮助?