NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
nim_cpp_client.h
浏览该文件的文档.
1
7#ifndef _NIM_SDK_CPP_CLIENT_H_
8#define _NIM_SDK_CPP_CLIENT_H_
9
10#include <thread>
12
14
19namespace nim {
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(std::string*)> RequestExtensionCallback;
39 typedef std::function<void(NIMResCode)> LogoutCallback;
41 typedef std::function<void(const KickoutRes&)> KickoutCallback;
43 typedef std::function<void(void)> DisconnectCallback;
45 typedef std::function<void(const MultiSpotLoginRes&)> MultiSpotLoginCallback;
47 typedef std::function<void(const KickOtherRes&)> KickOtherCallback;
49 typedef std::function<void(int, bool)> MultiportPushConfigCallback;
51 typedef std::function<void(int, bool, uint64_t)> GetCurrentServerTimeCallback;
52
53public:
68 static bool Init(const std::string& app_key, const std::string& app_data_dir, const std::string& app_install_dir, const SDKConfig& config);
69
75 static void SetCallbackFunction(const SDKClosure& callback);
76
81 static const SDKConfig& GetSDKConfig();
82
88 static void Cleanup(const std::string& json_extension = "");
89
95 static void Cleanup2(const std::string& json_extension = "");
96
103 static void LoginCustomDataToJson(const LoginParams& params, std::string& loginParams);
104
111 static void LoginCustomDataToJson(const std::string& custom_data, std::string& strValue);
112
136 static bool Login(const std::string& app_key,
137 const std::string& account,
138 const std::string& password,
139 const LoginCallback& cb,
140 const std::string& json_extension = "");
141
147 static NIMLoginState GetLoginState(const std::string& json_extension = "");
148
155 static void Relogin(const std::string& json_extension = "");
156
168 static void Logout(NIMLogoutType logout_type, const LogoutCallback& cb, const std::string& json_extension = "");
169
177 static bool KickOtherClient(const std::list<std::string>& client_ids);
178
197 static void RegReloginCb(const LoginCallback& cb, const std::string& json_extension = "");
198
208 static void RegReloginRequestToeknCb(const ReloginRequestTokenCallback& cb, const std::string& json_extension = "");
209
219 static void RegRequestLoginExtensionCb(const RequestExtensionCallback& cb, const std::string& json_extension = "");
220
227 static void RegKickoutCb(const KickoutCallback& cb, const std::string& json_extension = "");
228
237 static void RegDisconnectCb(const DisconnectCallback& cb, const std::string& json_extension = "");
238
247 static void RegMultispotLoginCb(const MultiSpotLoginCallback& cb, const std::string& json_extension = "");
248
258 static void RegKickOtherClientCb(const KickOtherCallback& cb, const std::string& json_extension = "");
259
268 static void RegSyncMultiportPushConfigCb(const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
269
280 static void SetMultiportPushConfigAsync(bool switch_on, const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
281
290 static void GetMultiportPushConfigAsync(const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
291
298 static std::string GetSDKVersion();
299
304 static std::string GetCurrentUserAccount();
305
317 static void GetServerCurrentTime(const Client::GetCurrentServerTimeCallback& cb, bool calc_local = false);
318
323 static void UnregClientCb();
324};
325
326} // namespace nim
327
328#endif //_NIM_SDK_CPP_CLIENT_H_
全局管理功能;主要包括SDK初始化/清理、客户端登录/退出等功能
Definition: nim_cpp_client.h:28
std::function< void(std::string *)> RequestExtensionCallback
登录时请求第三方鉴权扩展信息回调
Definition: nim_cpp_client.h:37
std::function< void(void)> DisconnectCallback
断网通知回调
Definition: nim_cpp_client.h:43
std::function< void(const MultiSpotLoginRes &)> MultiSpotLoginCallback
多端登录通知回调
Definition: nim_cpp_client.h:45
std::function< void(const LoginRes &)> LoginCallback
登录回调
Definition: nim_cpp_client.h:33
std::function< void(const KickoutRes &)> KickoutCallback
被踢通知回调
Definition: nim_cpp_client.h:41
std::function< void(std::string *)> ReloginRequestTokenCallback
登录时请求新的鉴权回调
Definition: nim_cpp_client.h:35
std::function< void(int, bool)> MultiportPushConfigCallback
多端推送控制开关回调
Definition: nim_cpp_client.h:49
std::function< void(int, bool, uint64_t)> GetCurrentServerTimeCallback
查询服务器当前时间回调
Definition: nim_cpp_client.h:51
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:47
std::function< void(NIMResCode)> LogoutCallback
登出回调
Definition: nim_cpp_client.h:39
namespace nim
void UnregNIMCallback()
Definition: nim_cpp_client.cpp:148
NIMLoginState
Definition: nim_client_def.h:73
NIMLogoutType
Definition: nim_client_def.h:91
Client 辅助方法和数据结构定义
定义导出宏
#define NIM_SDK_CPPWRAPPER_DLL_API
Definition: nim_sdk_cpp_wrapper.h:38
NIMResCode
Definition: public_defines.h:21
踢人结果回调信息
Definition: nim_client_helper.h:278
被踢结果回调信息
Definition: nim_client_helper.h:258
Definition: nim_client_helper.h:294
登录结果回调信息
Definition: nim_client_helper.h:240
多端登录回调信息
Definition: nim_client_helper.h:270
SDK初始化参数
Definition: nim_client_helper.h:25