NIM SDK API  9.0.0
nim_session_online_service_helper.h
Go to the documentation of this file.
1 
7 #ifndef _NIM_CPP_SESSION_ONLINE_SERVICE_HELPER_H_
8 #define _NIM_CPP_SESSION_ONLINE_SERVICE_HELPER_H_
9 
10 #include <functional>
11 #include <list>
12 #include <string>
16 #include "nim_define_include.h"
17 #include "nim_wrapper_util/nim_json_util.h"
22 namespace nim {
23 class NIM_SDK_CPPWRAPPER_DLL_API SessionOnLineServiceHelper {
24 public:
26  struct NIM_SDK_CPPWRAPPER_DLL_API SessionInfo {
27  SessionInfo()
28  : last_message_("")
29  , last_message_type_(0) {}
30  std::string id_;
31  NIMSessionType type_;
32  std::string ext_;
33  std::string last_message_;
34  uint64_t update_time_;
36  // 返回普通消息 auto last_msg = SessionInfo.GetLastMessage<0>();
37  template <int type>
38  auto GetLastMessage() const -> typename std::enable_if<type == 0, IMMessage>::type {
39  IMMessage msg;
40  ParseReceiveMessage(last_message_, msg);
41  return msg;
42  }
43  // 返回消息撤回通知auto last_msg = SessionInfo.GetLastMessage<1>();
44  template <int type>
45  auto GetLastMessage() const -> typename std::enable_if<type == 1, RecallMsgNotify>::type {
46  RecallMsgNotify recall_notify_msg;
47  ParseRecallMsgNotify(last_message_, recall_notify_msg);
48  return recall_notify_msg;
49  }
50  };
51  typedef std::list<SessionInfo> SessionList;
54  struct NIM_SDK_CPPWRAPPER_DLL_API QuerySessionListResult {
55  nim::NIMResCode res_code;
57  bool has_more_;
58  };
59  struct NIM_SDK_CPPWRAPPER_DLL_API DeleteSessionParam {
60  void AddSession(nim::NIMSessionType /*to_type */, std::string /*session_id */);
61  std::list<std::pair<nim::NIMSessionType /*to_type */, std::string /*session_id */>> delete_list_;
62  };
69  static bool ParseSessionInfo(const std::string& session_json, SessionInfo& session);
70 
77  static bool ParseQuerySessionListResult(const std::string& sessions_json, QuerySessionListResult& result);
78 
84  static std::string DeleteSessionParamToJsonString(const DeleteSessionParam& param);
85 };
86 } // namespace nim
87 
88 #endif //_NIM_CPP_SESSION_ONLINE_SERVICE_HELPER_H_
nim::SessionOnLineServiceHelper::SessionList
std::list< SessionInfo > SessionList
Definition: nim_session_online_service_helper.h:51
nim::SessionOnLineServiceHelper::SessionInfo::id_
std::string id_
Definition: nim_session_online_service_helper.h:30
nim::SessionOnLineServiceHelper::QuerySessionListResult::session_list_
SessionList session_list_
Definition: nim_session_online_service_helper.h:56
nim::SessionOnLineServiceHelper::DeleteSessionParam::delete_list_
std::list< std::pair< nim::NIMSessionType, std::string > > delete_list_
Definition: nim_session_online_service_helper.h:61
nim::ParseRecallMsgNotify
NIM_SDK_CPPWRAPPER_DLL_API bool ParseRecallMsgNotify(const std::string json_value, RecallMsgNotify &notify)
解析消息撤回通知
nim::ParseReceiveMessage
NIM_SDK_CPPWRAPPER_DLL_API bool ParseReceiveMessage(const std::string &msg_json, IMMessage &message)
解析消息
nim::RecallMsgNotify
消息撤回通知
Definition: nim_msg_helper.h:45
nim::SessionOnLineServiceHelper::SessionInfo::last_message_type_
int last_message_type_
Definition: nim_session_online_service_helper.h:35
nim_talk_helper.h
Talk 辅助方法和数据结构定义
nim::SessionOnLineServiceHelper::SessionInfo::ext_
std::string ext_
Definition: nim_session_online_service_helper.h:32
nim::SessionOnLineServiceHelper::SessionInfo
会话服务 会话数据定义
Definition: nim_session_online_service_helper.h:26
nim::SessionOnLineServiceHelper::SessionInfo::update_time_
uint64_t update_time_
Definition: nim_session_online_service_helper.h:34
nim
namespace nim
nim::SessionOnLineServiceHelper
Definition: nim_session_online_service_helper.h:23
nim::SessionOnLineServiceHelper::SessionInfo::type_
NIMSessionType type_
Definition: nim_session_online_service_helper.h:31
nim::SessionOnLineServiceHelper::DeleteSessionParam
Definition: nim_session_online_service_helper.h:59
nim::SessionOnLineServiceHelper::QuerySessionListResult
会话服务 查询会话列表应答数据定义
Definition: nim_session_online_service_helper.h:54
nim::SessionOnLineServiceHelper::QuerySessionListResult::res_code
nim::NIMResCode res_code
Definition: nim_session_online_service_helper.h:55
nim::SessionOnLineServiceHelper::SessionInfo::last_message_
std::string last_message_
Definition: nim_session_online_service_helper.h:33
nim_msg_helper.h
Message 通用辅助方法和数据结构定义
nim_sdk_cpp_wrapper.h
定义导出宏
nim::IMMessage
Definition: nim_talk_helper.h:242
nim::SessionOnLineServiceHelper::QuerySessionListResult::has_more_
bool has_more_
Definition: nim_session_online_service_helper.h:57