NIM PC Cross Platform SDK
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"
22namespace nim {
23class NIM_SDK_CPPWRAPPER_DLL_API SessionOnLineServiceHelper {
24public:
26 struct NIM_SDK_CPPWRAPPER_DLL_API SessionInfo {
28 : last_message_("")
29 , last_message_type_(0) {}
31 std::string id_;
35 std::string ext_;
37 std::string last_message_;
39 uint64_t update_time_;
42 // 返回普通消息 auto last_msg = SessionInfo.GetLastMessage<0>();
43 template <int type>
44 auto GetLastMessage() const -> typename std::enable_if<type == 0, IMMessage>::type {
45 IMMessage msg;
46 ParseReceiveMessage(last_message_, msg);
47 return msg;
48 }
49 // 返回消息撤回通知auto last_msg = SessionInfo.GetLastMessage<1>();
50 template <int type>
51 auto GetLastMessage() const -> typename std::enable_if<type == 1, RecallMsgNotify>::type {
52 RecallMsgNotify recall_notify_msg;
53 ParseRecallMsgNotify(last_message_, recall_notify_msg);
54 return recall_notify_msg;
55 }
56 };
58 typedef std::list<SessionInfo> SessionList;
59
61 struct NIM_SDK_CPPWRAPPER_DLL_API QuerySessionListResult {
68 };
69 struct NIM_SDK_CPPWRAPPER_DLL_API DeleteSessionParam {
70 void AddSession(nim::NIMSessionType /*to_type */, std::string /*session_id */);
72 std::list<std::pair<nim::NIMSessionType /*to_type */, std::string /*session_id */>> delete_list_;
73 };
80 static bool ParseSessionInfo(const std::string& session_json, SessionInfo& session);
81
88 static bool ParseQuerySessionListResult(const std::string& sessions_json, QuerySessionListResult& result);
89
95 static std::string DeleteSessionParamToJsonString(const DeleteSessionParam& param);
96};
97} // namespace nim
98
99#endif //_NIM_CPP_SESSION_ONLINE_SERVICE_HELPER_H_
Definition: nim_session_online_service_helper.h:23
std::list< SessionInfo > SessionList
会话列表
Definition: nim_session_online_service_helper.h:58
namespace nim
bool ParseReceiveMessage(const std::string &msg_json, IMMessage &message)
解析消息
Definition: nim_talk_helper.cpp:20
NIMResCode
Definition: nim_chatroom_res_code_def.h:15
NIM 公共数据类型定义总的包含文件
JSON辅助方法
Message 通用辅助方法和数据结构定义
定义导出宏
NIMSessionType
Definition: nim_session_def.h:16
Talk 辅助方法和数据结构定义
Definition: nim_talk_helper.h:281
消息撤回通知
Definition: nim_msg_helper.h:62
Definition: nim_session_online_service_helper.h:69
std::list< std::pair< nim::NIMSessionType, std::string > > delete_list_
list 要删除的会话
Definition: nim_session_online_service_helper.h:72
会话服务 查询会话列表应答数据定义
Definition: nim_session_online_service_helper.h:61
bool has_more_
是否还有会话数据
Definition: nim_session_online_service_helper.h:67
SessionList session_list_
会话列表
Definition: nim_session_online_service_helper.h:65
nim::NIMResCode res_code
返回的错误码 成功:200
Definition: nim_session_online_service_helper.h:63
会话服务 会话数据定义
Definition: nim_session_online_service_helper.h:26
int last_message_type_
最后一条消息的类型 0表示普通消息,1表示消息撤回通知
Definition: nim_session_online_service_helper.h:41
NIMSessionType type_
会话类型
Definition: nim_session_online_service_helper.h:33
uint64_t update_time_
最后更新时间戳
Definition: nim_session_online_service_helper.h:39
std::string id_
会话ID
Definition: nim_session_online_service_helper.h:31
std::string ext_
自定的扩展字段
Definition: nim_session_online_service_helper.h:35
std::string last_message_
最后一条会话 json string
Definition: nim_session_online_service_helper.h:37