NIM PC Cross Platform SDK
nim_cpp_client.h
Go to the documentation of this file.
1
7#ifndef _NIM_SDK_CPP_CLIENT_H_
8#define _NIM_SDK_CPP_CLIENT_H_
9
10#include <thread>
12
14
19namespace nim {
24NIM_SDK_CPPWRAPPER_DLL_API void UnregNIMCallback();
28class NIM_SDK_CPPWRAPPER_DLL_API Client {
29public:
31 typedef std::function<void(const std::function<void()>&)> SDKClosure;
33 typedef std::function<void(const LoginRes&)> LoginCallback;
35 typedef std::function<void(std::string*)> ReloginRequestTokenCallback;
37 typedef std::function<void(NIMResCode)> LogoutCallback;
39 typedef std::function<void(const KickoutRes&)> KickoutCallback;
41 typedef std::function<void(void)> DisconnectCallback;
43 typedef std::function<void(const MultiSpotLoginRes&)> MultiSpotLoginCallback;
45 typedef std::function<void(const KickOtherRes&)> KickOtherCallback;
47 typedef std::function<void(int, bool)> MultiportPushConfigCallback;
49 typedef std::function<void(int, bool, uint64_t)> GetCurrentServerTimeCallback;
50
51public:
61 static bool Init(const std::string& app_key, const std::string& app_data_dir, const std::string& app_install_dir, const SDKConfig& config);
62
68 static void SetCallbackFunction(const SDKClosure& callback);
69
74 static const SDKConfig& GetSDKConfig();
75
81 static void Cleanup(const std::string& json_extension = "");
82
88 static void Cleanup2(const std::string& json_extension = "");
89
96 static void LoginCustomDataToJson(const LoginParams& params, std::string& loginParams);
97
104 static void LoginCustomDataToJson(const std::string& custom_data, std::string& strValue);
105
124 static bool Login(const std::string& app_key,
125 const std::string& account,
126 const std::string& password,
127 const LoginCallback& cb,
128 const std::string& json_extension = "");
129
135 static NIMLoginState GetLoginState(const std::string& json_extension = "");
136
142 static void Relogin(const std::string& json_extension = "");
143
153 static void Logout(NIMLogoutType logout_type, const LogoutCallback& cb, const std::string& json_extension = "");
154
160 static bool KickOtherClient(const std::list<std::string>& client_ids);
161
176 static void RegReloginCb(const LoginCallback& cb, const std::string& json_extension = "");
177
185 static void RegReloginRequestToeknCb(const ReloginRequestTokenCallback& cb, const std::string& json_extension = "");
186
193 static void RegKickoutCb(const KickoutCallback& cb, const std::string& json_extension = "");
194
201 static void RegDisconnectCb(const DisconnectCallback& cb, const std::string& json_extension = "");
202
209 static void RegMultispotLoginCb(const MultiSpotLoginCallback& cb, const std::string& json_extension = "");
210
218 static void RegKickOtherClientCb(const KickOtherCallback& cb, const std::string& json_extension = "");
219
226 static void RegSyncMultiportPushConfigCb(const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
227
236 static void SetMultiportPushConfigAsync(bool switch_on, const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
237
244 static void GetMultiportPushConfigAsync(const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
245
250 static std::string GetSDKVersion();
251
256 static std::string GetCurrentUserAccount();
257
267 static void GetServerCurrentTime(const Client::GetCurrentServerTimeCallback& cb, bool calc_local = false);
268
273 static void UnregClientCb();
274};
275
276} // namespace nim
277
278#endif //_NIM_SDK_CPP_CLIENT_H_
全局管理功能;主要包括SDK初始化/清理、客户端登录/退出等功能
Definition: nim_cpp_client.h:28
std::function< void(void)> DisconnectCallback
断网通知回调模板
Definition: nim_cpp_client.h:41
std::function< void(const MultiSpotLoginRes &)> MultiSpotLoginCallback
多端登录通知回调模板
Definition: nim_cpp_client.h:43
std::function< void(const LoginRes &)> LoginCallback
登录回调模板
Definition: nim_cpp_client.h:33
std::function< void(const KickoutRes &)> KickoutCallback
被踢通知回调模板
Definition: nim_cpp_client.h:39
std::function< void(std::string *)> ReloginRequestTokenCallback
自动重连时请求新的鉴权回调
Definition: nim_cpp_client.h:35
std::function< void(int, bool)> MultiportPushConfigCallback
多端推送控制开关回调模板
Definition: nim_cpp_client.h:47
std::function< void(int, bool, uint64_t)> GetCurrentServerTimeCallback
查询服务器当前时间回调模板
Definition: nim_cpp_client.h:49
std::function< void(const std::function< void()> &)> SDKClosure
默认回调模板
Definition: nim_cpp_client.h:31
std::function< void(const KickOtherRes &)> KickOtherCallback
将多端下线回调模板
Definition: nim_cpp_client.h:45
std::function< void(NIMResCode)> LogoutCallback
登出回调模板
Definition: nim_cpp_client.h:37
namespace nim
void UnregNIMCallback()
Definition: nim_cpp_client.cpp:148
NIMResCode
Definition: nim_chatroom_res_code_def.h:15
NIMLoginState
Definition: nim_client_def.h:73
NIMLogoutType
Definition: nim_client_def.h:91
Client 辅助方法和数据结构定义
定义导出宏
踢人结果回调信息
Definition: nim_client_helper.h:250
被踢结果回调信息
Definition: nim_client_helper.h:230
Definition: nim_client_helper.h:266
登录结果回调信息
Definition: nim_client_helper.h:212
多端登录回调信息
Definition: nim_client_helper.h:242
SDK设置项
Definition: nim_client_helper.h:26