NIM SDK API  8.5.0
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>
11 #include "nim_cpp_wrapper/nim_sdk_cpp_wrapper.h"
12 
14 
19 namespace nim {
24 NIM_SDK_CPPWRAPPER_DLL_API void UnregNIMCallback();
28 class NIM_SDK_CPPWRAPPER_DLL_API Client {
29 public:
30  typedef std::function<void(const std::function<void()>&)> SDKClosure;
31  typedef std::function<void(const LoginRes&)> LoginCallback;
32  typedef std::function<void(std::string*)> ReloginRequestTokenCallback;
33  typedef std::function<void(NIMResCode)> LogoutCallback;
34  typedef std::function<void(const KickoutRes&)> KickoutCallback;
35  typedef std::function<void(void)> DisconnectCallback;
36  typedef std::function<void(const MultiSpotLoginRes&)> MultiSpotLoginCallback;
37  typedef std::function<void(const KickOtherRes&)> KickOtherCallback;
38  typedef std::function<void(int, bool)> MultiportPushConfigCallback;
39  typedef std::function<void(int, bool, uint64_t)> GetCurrentServerTimeCallback;
41 public:
51  static bool Init(const std::string& app_key, const std::string& app_data_dir, const std::string& app_install_dir, const SDKConfig& config);
52 
58  static void SetCallbackFunction(const SDKClosure& callback);
59 
64  static const SDKConfig& GetSDKConfig();
65 
71  static void Cleanup(const std::string& json_extension = "");
72 
78  static void Cleanup2(const std::string& json_extension = "");
79 
86  static void LoginCustomDataToJson(const LoginParams& params, std::string& loginParams);
87 
94  static void LoginCustomDataToJson(const std::string& custom_data, std::string& strValue);
95 
114  static bool Login(const std::string& app_key,
115  const std::string& account,
116  const std::string& password,
117  const LoginCallback& cb,
118  const std::string& json_extension = "");
119 
125  static NIMLoginState GetLoginState(const std::string& json_extension = "");
126 
132  static void Relogin(const std::string& json_extension = "");
133 
143  static void Logout(NIMLogoutType logout_type, const LogoutCallback& cb, const std::string& json_extension = "");
144 
150  static bool KickOtherClient(const std::list<std::string>& client_ids);
151 
166  static void RegReloginCb(const LoginCallback& cb, const std::string& json_extension = "");
167 
175  static void RegReloginRequestToeknCb(const ReloginRequestTokenCallback& cb, const std::string& json_extension = "");
176 
183  static void RegKickoutCb(const KickoutCallback& cb, const std::string& json_extension = "");
184 
191  static void RegDisconnectCb(const DisconnectCallback& cb, const std::string& json_extension = "");
192 
199  static void RegMultispotLoginCb(const MultiSpotLoginCallback& cb, const std::string& json_extension = "");
200 
208  static void RegKickOtherClientCb(const KickOtherCallback& cb, const std::string& json_extension = "");
209 
216  static void RegSyncMultiportPushConfigCb(const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
217 
226  static void SetMultiportPushConfigAsync(bool switch_on, const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
227 
234  static void GetMultiportPushConfigAsync(const MultiportPushConfigCallback& cb, const std::string& json_extension = "");
235 
240  static std::string GetSDKVersion();
241 
246  static std::string GetCurrentUserAccount();
247 
257  static void GetServerCurrentTime(const Client::GetCurrentServerTimeCallback& cb, bool calc_local = false);
258 
263  static void UnregClientCb();
264 };
265 
266 } // namespace nim
267 
268 #endif //_NIM_SDK_CPP_CLIENT_H_
nim::Client::GetCurrentServerTimeCallback
std::function< void(int, bool, uint64_t)> GetCurrentServerTimeCallback
Definition: nim_cpp_client.h:39
nim::Client
全局管理功能;主要包括SDK初始化/清理、客户端登录/退出等功能
Definition: nim_cpp_client.h:28
nim::KickOtherRes
踢人结果回调信息
Definition: nim_client_helper.h:163
nim::Client::ReloginRequestTokenCallback
std::function< void(std::string *)> ReloginRequestTokenCallback
Definition: nim_cpp_client.h:32
nim::UnregNIMCallback
NIM_SDK_CPPWRAPPER_DLL_API void UnregNIMCallback()
nim::KickoutRes
被踢结果回调信息
Definition: nim_client_helper.h:149
nim::SDKConfig
SDK设置项
Definition: nim_client_helper.h:26
nim::LoginParams
Definition: nim_client_helper.h:176
nim_client_helper.h
Client 辅助方法和数据结构定义
nim::LoginRes
登录结果回调信息
Definition: nim_client_helper.h:136
nim::Client::KickoutCallback
std::function< void(const KickoutRes &)> KickoutCallback
Definition: nim_cpp_client.h:34
nim::Client::MultiSpotLoginCallback
std::function< void(const MultiSpotLoginRes &)> MultiSpotLoginCallback
Definition: nim_cpp_client.h:36
nim::Client::LogoutCallback
std::function< void(NIMResCode)> LogoutCallback
Definition: nim_cpp_client.h:33
nim::Client::LoginCallback
std::function< void(const LoginRes &)> LoginCallback
Definition: nim_cpp_client.h:31
nim
namespace nim
nim_http::Init
void Init(const std::wstring &dll_path=L"")
Definition: nim_tools_http_cpp.h:65
nim::Client::KickOtherCallback
std::function< void(const KickOtherRes &)> KickOtherCallback
Definition: nim_cpp_client.h:37
nim::MultiSpotLoginRes
多端登录回调信息
Definition: nim_client_helper.h:157
nim::Client::MultiportPushConfigCallback
std::function< void(int, bool)> MultiportPushConfigCallback
Definition: nim_cpp_client.h:38
nim::Client::DisconnectCallback
std::function< void(void)> DisconnectCallback
Definition: nim_cpp_client.h:35