NIM SDK API  8.5.0
nim_talk_helper.h
Go to the documentation of this file.
1 
7 #ifndef _NIM_SDK_CPP_TALK_HELPER_H_
8 #define _NIM_SDK_CPP_TALK_HELPER_H_
9 
10 #include <functional>
11 #include <list>
12 #include <string>
13 #include "nim_define_include.h"
15 #include "nim_cpp_wrapper/nim_sdk_cpp_wrapper.h"
16 #include "nim_wrapper_util/nim_json_util.h"
21 namespace nim {
22 
24 struct NIM_SDK_CPPWRAPPER_DLL_API MessageSetting {
25  BoolStatus resend_flag_;
26  BoolStatus server_history_saved_;
27  BoolStatus roaming_;
28  BoolStatus self_sync_;
29  BoolStatus need_push_;
30  BoolStatus push_need_badge_;
31  BoolStatus push_need_prefix_;
32  BoolStatus routable_;
33  BoolStatus need_offline_;
34  nim_cpp_wrapper_util::Json::Value push_payload_;
35  std::string push_content_;
36  nim_cpp_wrapper_util::Json::Value server_ext_;
37  std::string local_ext_;
38  BoolStatus is_force_push_;
39  std::list<std::string> force_push_ids_list_;
40  std::string force_push_content_;
41  BoolStatus anti_spam_enable_;
42  std::string anti_spam_content_;
43  std::string anti_apam_biz_id_;
47  BoolStatus team_msg_need_ack_;
48  BoolStatus team_msg_ack_sent_;
50  BoolStatus is_update_session_;
51  std::string yidun_anti_cheating_;
52  std::string env_config_;
56  : resend_flag_(BS_NOT_INIT)
57  , server_history_saved_(BS_NOT_INIT)
58  , roaming_(BS_NOT_INIT)
59  , self_sync_(BS_NOT_INIT)
60  , need_push_(BS_NOT_INIT)
61  , push_need_badge_(BS_NOT_INIT)
62  , push_need_prefix_(BS_NOT_INIT)
63  , routable_(BS_NOT_INIT)
64  , need_offline_(BS_NOT_INIT)
65  , is_force_push_(BS_NOT_INIT)
66  , anti_spam_enable_(BS_NOT_INIT)
67  , anti_apam_biz_id_("")
68  , anti_apam_using_yidun_(1)
69  , client_anti_spam_hitting_(BS_NOT_INIT)
70  , team_msg_need_ack_(BS_NOT_INIT)
71  , team_msg_ack_sent_(BS_NOT_INIT)
72  , team_msg_unread_count_(-1)
73  , is_update_session_(BS_NOT_INIT)
74  , yidun_anti_cheating_("")
75  , env_config_("") {}
76 
82  void ToJsonValue(nim_cpp_wrapper_util::Json::Value& message) const {
83  if (server_history_saved_ != BS_NOT_INIT)
84  message[kNIMMsgKeyHistorySave] = server_history_saved_;
85  if (roaming_ != BS_NOT_INIT)
86  message[kNIMMsgKeyMsgRoaming] = roaming_;
87  if (self_sync_ != BS_NOT_INIT)
88  message[kNIMMsgKeyMsgSync] = self_sync_;
89  if (push_need_badge_ != BS_NOT_INIT)
90  message[kNIMMsgKeyPushNeedBadge] = push_need_badge_;
91  if (need_push_ != BS_NOT_INIT)
92  message[kNIMMsgKeyPushEnable] = need_push_;
93  if (push_need_prefix_ != BS_NOT_INIT)
94  message[kNIMMsgKeyPushNeedPrefix] = push_need_prefix_;
95  if (resend_flag_ != BS_NOT_INIT)
96  message[kNIMMsgKeyResendFlag] = resend_flag_;
97  if (routable_ != BS_NOT_INIT)
98  message[kNIMMsgKeyMsgRoutable] = routable_;
99  if (need_offline_ != BS_NOT_INIT)
100  message[kNIMMsgKeySetMsgOffline] = need_offline_;
101  if (!push_payload_.empty())
102  message[kNIMMsgKeyPushPayload] = GetJsonStringWithNoStyled(push_payload_);
103  if (!push_content_.empty())
104  message[kNIMMsgKeyPushContent] = push_content_;
105  if (!server_ext_.empty())
106  message[kNIMMsgKeyServerExt] = GetJsonStringWithNoStyled(server_ext_);
107  if (!local_ext_.empty())
108  message[kNIMMsgKeyLocalExt] = local_ext_;
109  if (is_force_push_ != BS_NOT_INIT)
110  message[kNIMMsgKeyIsForcePush] = is_force_push_ == BS_TRUE ? 1 : 0;
111  if (!force_push_content_.empty())
112  message[kNIMMsgKeyForcePushContent] = force_push_content_;
113  if (!force_push_ids_list_.empty()) {
114  std::string ids_json;
115  StrListToJsonString(force_push_ids_list_, ids_json);
116  message[kNIMMsgKeyForcePushList] = ids_json;
117  }
118  if (anti_spam_enable_ != BS_NOT_INIT)
119  message[kNIMMsgKeyAntiSpamEnable] = anti_spam_enable_ == BS_TRUE ? 1 : 0;
120  if (!anti_spam_content_.empty())
121  message[kNIMMsgKeyAntiSpamContent] = anti_spam_content_;
122  if (!anti_apam_biz_id_.empty())
123  message[kNIMMsgKeyAntiSpamBizId] = anti_apam_biz_id_;
124  message[kNIMMsgKeyAntiSpamUsingYiDun] = anti_apam_using_yidun_;
125  if (client_anti_spam_hitting_ != BS_NOT_INIT)
126  message[kNIMMsgKeyClientAntiSpam] = client_anti_spam_hitting_;
127  if (team_msg_need_ack_ != BS_NOT_INIT)
128  message[kNIMMsgKeyTeamMsgAck] = team_msg_need_ack_;
129  if (team_msg_ack_sent_ != BS_NOT_INIT)
130  message[kNIMMsgKeyLocalKeyTeamMsgAckSent] = team_msg_ack_sent_;
131  if (team_msg_unread_count_ > -1)
132  message[kNIMMsgKeyLocalKeyTeamMsgUnreadCount] = team_msg_unread_count_;
133  if (is_update_session_ != BS_NOT_INIT)
134  message[kNIMMsgKeyIsUpdateSession] = is_update_session_;
135  if (!yidun_anti_cheating_.empty())
136  message[kNIMMsgKeyYiDunAntiCheating] = yidun_anti_cheating_;
137  if (!env_config_.empty())
138  message[kNIMMsgKeyEnv] = env_config_;
139  }
140 
146  void ParseMessageSetting(const nim_cpp_wrapper_util::Json::Value& message) {
147  if (message.isMember(kNIMMsgKeyHistorySave))
148  server_history_saved_ = message[kNIMMsgKeyHistorySave].asInt() == 1 ? BS_TRUE : BS_FALSE;
149  if (message.isMember(kNIMMsgKeyMsgRoaming))
150  roaming_ = message[kNIMMsgKeyMsgRoaming].asInt() == 1 ? BS_TRUE : BS_FALSE;
151  if (message.isMember(kNIMMsgKeyMsgSync))
152  self_sync_ = message[kNIMMsgKeyMsgSync].asInt() == 1 ? BS_TRUE : BS_FALSE;
153  if (message.isMember(kNIMMsgKeyPushNeedBadge))
154  push_need_badge_ = message[kNIMMsgKeyPushNeedBadge].asInt() == 1 ? BS_TRUE : BS_FALSE;
155  if (message.isMember(kNIMMsgKeyPushEnable))
156  need_push_ = message[kNIMMsgKeyPushEnable].asInt() == 1 ? BS_TRUE : BS_FALSE;
157  if (message.isMember(kNIMMsgKeyPushNeedPrefix))
158  push_need_prefix_ = message[kNIMMsgKeyPushNeedPrefix].asInt() == 1 ? BS_TRUE : BS_FALSE;
159  if (message.isMember(kNIMMsgKeyResendFlag))
160  resend_flag_ = message[kNIMMsgKeyResendFlag].asInt() == 1 ? BS_TRUE : BS_FALSE;
161  if (message.isMember(kNIMMsgKeyMsgRoutable))
162  routable_ = message[kNIMMsgKeyMsgRoutable].asInt() == 1 ? BS_TRUE : BS_FALSE;
163  if (message.isMember(kNIMMsgKeySetMsgOffline))
164  need_offline_ = message[kNIMMsgKeySetMsgOffline].asInt() == 1 ? BS_TRUE : BS_FALSE;
165  nim_cpp_wrapper_util::Json::Reader reader;
166  if (message.isMember(kNIMMsgKeyServerExt) && !message[kNIMMsgKeyServerExt].asString().empty())
167  if ((!reader.parse(message[kNIMMsgKeyServerExt].asString(), server_ext_) || !server_ext_.isObject())) {
168  }
169  if (message.isMember(kNIMMsgKeyPushPayload) && !message[kNIMMsgKeyPushPayload].asString().empty())
170  if (!reader.parse(message[kNIMMsgKeyPushPayload].asString(), push_payload_) || !push_payload_.isObject()) {
171  }
172  local_ext_ = message[kNIMMsgKeyLocalExt].asString();
173  push_content_ = message[kNIMMsgKeyPushContent].asString();
174  if (message.isMember(kNIMMsgKeyIsForcePush))
175  is_force_push_ = message[kNIMMsgKeyIsForcePush].asInt() == 1 ? BS_TRUE : BS_FALSE;
176  force_push_content_ = message[kNIMMsgKeyForcePushContent].asString();
177  if (message[kNIMMsgKeyForcePushList].isString()) {
178  nim_cpp_wrapper_util::Json::Value values;
179  if (reader.parse(message[kNIMMsgKeyForcePushList].asString(), values) && values.isArray())
180  JsonStrArrayToList(values, force_push_ids_list_);
181  else {
182  // assert(0);
183  }
184  }
185  if (message.isMember(kNIMMsgKeyAntiSpamEnable))
186  anti_spam_enable_ = message[kNIMMsgKeyAntiSpamEnable].asInt() == 1 ? BS_TRUE : BS_FALSE;
187  anti_spam_content_ = message[kNIMMsgKeyAntiSpamContent].asString();
188  if (message.isMember(kNIMMsgKeyClientAntiSpam))
189  client_anti_spam_hitting_ = message[kNIMMsgKeyClientAntiSpam].asInt() == 1 ? BS_TRUE : BS_FALSE;
190  if (message.isMember(kNIMMsgKeyTeamMsgAck))
191  team_msg_need_ack_ = message[kNIMMsgKeyTeamMsgAck].asInt() == 1 ? BS_TRUE : BS_FALSE;
192  if (message.isMember(kNIMMsgKeyLocalKeyTeamMsgAckSent))
193  team_msg_ack_sent_ = message[kNIMMsgKeyTeamMsgAck].asInt() == 1 ? BS_TRUE : BS_FALSE;
194  if (message.isMember(kNIMMsgKeyLocalKeyTeamMsgUnreadCount))
195  team_msg_unread_count_ = message[kNIMMsgKeyLocalKeyTeamMsgUnreadCount].asUInt();
196  if (message.isMember(kNIMMsgKeyIsUpdateSession))
197  is_update_session_ = message[kNIMMsgKeyIsUpdateSession].asBool() ? BS_TRUE : BS_FALSE;
198  if (message.isMember(kNIMMsgKeyYiDunAntiCheating))
199  yidun_anti_cheating_ = message[kNIMMsgKeyYiDunAntiCheating].asString();
200  if (message.isMember(kNIMMsgKeyEnv))
201  env_config_ = message[kNIMMsgKeyEnv].asString();
202  }
203 };
204 
206 struct NIM_SDK_CPPWRAPPER_DLL_API IMMessageThreadInfo {
207  std::string reply_msg_from_account_; //被回复消息的消息发送者
208  std::string reply_msg_to_account_; // 被回复消息的消息接受者,群的话是tid
209  uint64_t reply_msg_time_; // 被回复消息的消息发送时间
210  uint64_t reply_msg_id_server_; // 被回复消息的消息ID(serverId)
211  std::string reply_msg_id_client_; // 被回复消息的消息ID(clientId)
212 
213  std::string thread_msg_from_account_; // thread消息的消息发送者
214  std::string thread_msg_to_account_; // thread消息的消息接受者,群的话是tid
215  uint64_t thread_msg_time_; // thread消息的消息发送时间
216  uint64_t thread_msg_id_server_; // thread消息的消息ID(serverId)
217  std::string thread_msg_id_client_; // thread消息的消息ID(clientId)
218  int deleted_; // 消息是否已经被删除(可能是撤回,也可能是单向删除),查询thread消息历史时可能会有这个字段,大于0表示已经删除(目前撤回和单向删除都是1,未来可能区分)
220  : reply_msg_from_account_("")
221  , reply_msg_to_account_("")
222  , reply_msg_time_(0)
223  , reply_msg_id_server_(0)
224  , reply_msg_id_client_("")
225  , thread_msg_from_account_("")
226  , thread_msg_to_account_("")
227  , thread_msg_time_(0)
228  , thread_msg_id_server_(0)
229  , thread_msg_id_client_("")
230  , deleted_(0) {}
231 };
232 struct NIM_SDK_CPPWRAPPER_DLL_API IMMessage {
233 public:
234  NIMResCode rescode_;
235  NIMMessageFeature feature_;
237 public:
238  NIMSessionType session_type_;
239  std::string receiver_accid_;
240  std::string sender_accid_;
241  int64_t timetag_;
242  std::string content_;
243  NIMMessageType type_;
244  std::string attach_;
245  std::string client_msg_id_;
248  int32_t sub_type_;
249 public:
250  std::string local_res_path_;
251  std::string local_talk_id_;
252  std::string local_res_id_;
253  NIMMsgLogStatus status_;
254  NIMMsgLogSubStatus sub_status_;
255 public:
256  IMMessageThreadInfo thread_info_;
257 
258 public:
266  : rescode_((NIMResCode)0)
267  , feature_(kNIMMessageFeatureDefault)
268  , readonly_sender_client_type_(kNIMClientTypeDefault)
269  , readonly_server_id_(0)
270  , session_type_(kNIMSessionTypeP2P)
271  , timetag_(0)
272  , type_(kNIMMessageTypeUnknown)
273  , status_(nim::kNIMMsgLogStatusNone)
274  , sub_status_(nim::kNIMMsgLogSubStatusNone) {}
275 
277  IMMessage(const std::string& json_msg)
278  : rescode_((NIMResCode)0)
279  , feature_(kNIMMessageFeatureDefault)
280  , readonly_sender_client_type_(kNIMClientTypeDefault)
281  , readonly_server_id_(0)
282  , session_type_(kNIMSessionTypeP2P)
283  , timetag_(0)
284  , type_(kNIMMessageTypeUnknown)
285  , status_(nim::kNIMMsgLogStatusNone)
286  , sub_status_(nim::kNIMMsgLogSubStatusNone) {
287  nim_cpp_wrapper_util::Json::Value values;
288  nim_cpp_wrapper_util::Json::Reader reader;
289  if (reader.parse(json_msg, values) && values.isObject()) {
290  session_type_ = (NIMSessionType)values[kNIMMsgKeyToType].asUInt();
291  receiver_accid_ = values[kNIMMsgKeyToAccount].asString();
292  sender_accid_ = values[kNIMMsgKeyFromAccount].asString();
293  readonly_sender_client_type_ = (NIMClientType)values[kNIMMsgKeyFromClientType].asUInt();
294  readonly_sender_device_id_ = values[kNIMMsgKeyFromDeviceId].asString();
295  readonly_sender_nickname_ = values[kNIMMsgKeyFromNick].asString();
296  timetag_ = values[kNIMMsgKeyTime].asUInt64();
297 
298  type_ = (NIMMessageType)values[kNIMMsgKeyType].asUInt();
299  content_ = values[kNIMMsgKeyBody].asString();
300  attach_ = values[kNIMMsgKeyAttach].asString();
301  client_msg_id_ = values[kNIMMsgKeyClientMsgid].asString();
302  readonly_server_id_ = values[kNIMMsgKeyServerMsgid].asUInt64();
303 
304  local_res_path_ = values[kNIMMsgKeyLocalFilePath].asString();
305  local_talk_id_ = values[kNIMMsgKeyLocalTalkId].asString();
306  local_res_id_ = values[kNIMMsgKeyLocalResId].asString();
307  status_ = (NIMMsgLogStatus)values[kNIMMsgKeyLocalLogStatus].asUInt();
308  sub_status_ = (NIMMsgLogSubStatus)values[kNIMMsgKeyLocalLogSubStatus].asUInt();
309 
310  msg_setting_.ParseMessageSetting(values);
311 
312  // v7.8 <--
313  third_party_callback_ext_ = values[kNIMMsgKeyThirdPartyCBEXT].asString();
314  sub_type_ = values[kNIMMsgKeySubType].asInt();
315  // --> v7.8
316  }
317  }
318 
323  nim_cpp_wrapper_util::Json::Value ToJsonObject(bool use_to_send) const {
324  nim_cpp_wrapper_util::Json::Value values;
325  values[kNIMMsgKeyToType] = session_type_;
326  values[kNIMMsgKeyToAccount] = receiver_accid_;
327  values[kNIMMsgKeyFromAccount] = sender_accid_;
328  values[kNIMMsgKeyTime] = timetag_;
329  values[kNIMMsgKeyType] = type_;
330  values[kNIMMsgKeyBody] = content_;
331  values[kNIMMsgKeyAttach] = attach_;
332  values[kNIMMsgKeyClientMsgid] = client_msg_id_;
333  values[kNIMMsgKeyLocalFilePath] = local_res_path_;
334  values[kNIMMsgKeyLocalTalkId] = local_talk_id_;
335  values[kNIMMsgKeyLocalResId] = local_res_id_;
336  values[kNIMMsgKeyLocalLogStatus] = status_;
337  values[kNIMMsgKeyLocalLogSubStatus] = sub_status_;
338  values[kNIMMsgKeySubType] = sub_type_;
339  msg_setting_.ToJsonValue(values);
340 
341  if (!use_to_send) {
342  values[kNIMMsgKeyFromClientType] = readonly_sender_client_type_;
343  values[kNIMMsgKeyFromDeviceId] = readonly_sender_device_id_;
344  values[kNIMMsgKeyFromNick] = readonly_sender_nickname_;
345  values[kNIMMsgKeyServerMsgid] = readonly_server_id_;
346  values[kNIMMsgKeyThirdPartyCBEXT] = third_party_callback_ext_;
347  }
348  // thread
349  {
350  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyReplyMsgFromAccount] = thread_info_.reply_msg_from_account_;
351  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyReplyMsgToAccount] = thread_info_.reply_msg_to_account_;
352  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyReplyMsgTime] = thread_info_.reply_msg_time_;
353  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyReplyMsgIdServer] = thread_info_.reply_msg_id_server_;
354  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyReplyMsgIdClient] = thread_info_.reply_msg_id_client_;
355 
356  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyThreadMsgFromAccount] = thread_info_.thread_msg_from_account_;
357  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyThreadMsgToAccount] = thread_info_.thread_msg_to_account_;
358  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyThreadMsgTime] = thread_info_.thread_msg_time_;
359  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyThreadMsgIdServer] = thread_info_.thread_msg_id_server_;
360  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyThreadMsgIdClient] = thread_info_.thread_msg_id_client_;
361 
362  values[kNIMMsgKeyThreadInfo][kNIMMsgKeyDeleted] = thread_info_.deleted_;
363  }
364  return values;
365  }
366 
371  std::string ToJsonString(bool use_to_send) const {
372  nim_cpp_wrapper_util::Json::Value values = ToJsonObject(use_to_send);
373  return GetJsonStringWithNoStyled(values);
374  }
375 };
376 
378 struct NIM_SDK_CPPWRAPPER_DLL_API IMFile {
379  std::string md5_;
380  int64_t size_;
381  std::string url_;
382  std::string display_name_;
383  std::string file_extension_;
384  std::string msg_attachment_tag_;
388  : size_(0)
389  , msg_attachment_tag_(kNIMNosDefaultTagIM) {}
390 
396  std::string ToJsonString(nim_cpp_wrapper_util::Json::Value& attach) const {
397  //以下客户端可以选填
398  if (!display_name_.empty())
399  attach[kNIMFileMsgKeyDisplayName] = display_name_;
400  if (!file_extension_.empty())
401  attach[kNIMFileMsgKeyExt] = file_extension_;
402  if (!md5_.empty())
403  attach[kNIMFileMsgKeyMd5] = md5_;
404  if (size_ > 0)
405  attach[kNIMFileMsgKeySize] = size_;
406  if (!url_.empty())
407  attach[kNIMMsgAttachKeyUrl] = url_;
408  if (!msg_attachment_tag_.empty())
409  attach[kNIMMsgAttachKeyTag] = msg_attachment_tag_;
410  return GetJsonStringWithNoStyled(attach);
411  }
412 
417  std::string ToJsonString() const {
418  nim_cpp_wrapper_util::Json::Value attach;
419  attach[kNIMFileMsgKeyDisplayName] = display_name_;
420  return ToJsonString(attach);
421  }
422 };
423 
425 struct NIM_SDK_CPPWRAPPER_DLL_API IMImage : IMFile {
426  int width_;
427  int height_;
431  : width_(0)
432  , height_(0) {}
433 
438  std::string ToJsonString() const {
439  nim_cpp_wrapper_util::Json::Value attach;
440  attach[kNIMImgMsgKeyWidth] = width_;
441  attach[kNIMImgMsgKeyHeight] = height_;
442 
443  return IMFile::ToJsonString(attach); // remove the Visual C++ __super keyword.
444  }
445 };
446 
448 struct NIM_SDK_CPPWRAPPER_DLL_API IMLocation {
449  std::string description_;
450  double latitude_;
451  double longitude_;
455  : latitude_(0)
456  , longitude_(0) {}
457 
462  std::string ToJsonString() const {
463  nim_cpp_wrapper_util::Json::Value attach;
464  attach[kNIMLocationMsgKeyTitle] = description_;
465  attach[kNIMLocationMsgKeyLatitude] = latitude_;
466  attach[kNIMLocationMsgKeyLongitude] = longitude_;
467 
468  return GetJsonStringWithNoStyled(attach);
469  }
470 };
471 
473 struct NIM_SDK_CPPWRAPPER_DLL_API IMAudio : IMFile {
474  int duration_;
478  : duration_(0) {}
479 
484  std::string ToJsonString() const {
485  nim_cpp_wrapper_util::Json::Value attach;
486  attach[kNIMAudioMsgKeyDuration] = duration_;
487 
488  return IMFile::ToJsonString(attach); // remove the Visual C++ __super keyword.
489  }
490 };
491 
493 struct NIM_SDK_CPPWRAPPER_DLL_API IMVideo : IMFile {
494  int duration_;
495  int width_;
496  int height_;
500  : duration_(0)
501  , width_(0)
502  , height_(0) {}
503 
508  std::string ToJsonString() const {
509  nim_cpp_wrapper_util::Json::Value attach;
510  attach[kNIMVideoMsgKeyWidth] = width_;
511  attach[kNIMVideoMsgKeyHeight] = height_;
512  attach[kNIMVideoMsgKeyDuration] = duration_;
513 
514  return IMFile::ToJsonString(attach); // remove the Visual C++ __super keyword.
515  }
516 };
517 
519 struct NIM_SDK_CPPWRAPPER_DLL_API IMBotRobot {
520  bool out_msg_;
521  std::string robot_accid_;
522  nim_cpp_wrapper_util::Json::Value sent_param_;
524  std::string related_msg_id_;
525  std::string robot_msg_flag_;
526  nim_cpp_wrapper_util::Json::Value robot_msg_content_;
530  : out_msg_(false) {}
531 
536  std::string ToJsonString() const {
537  nim_cpp_wrapper_util::Json::Value attach;
538  attach[kNIMBotRobotMsgKeyRobotID] = robot_accid_;
539  attach[kNIMBotRobotSentMsgKeyParam] = sent_param_;
540 
541  return GetJsonStringWithNoStyled(attach);
542  }
543 };
544 
545 struct NIM_SDK_CPPWRAPPER_DLL_API BroadcastMessage {
546  std::string body_;
547  int64_t time_;
548  int64_t id_;
549  std::string from_id_;
550 };
551 
558 NIM_SDK_CPPWRAPPER_DLL_API bool ParseMessage(const std::string& msg_json, IMMessage& message);
559 
566 NIM_SDK_CPPWRAPPER_DLL_API bool ParseReceiveMessage(const std::string& msg_json, IMMessage& message);
567 
574 NIM_SDK_CPPWRAPPER_DLL_API void ParseReceiveMessage(const nim_cpp_wrapper_util::Json::Value& msg_json_value, IMMessage& message);
575 
582 NIM_SDK_CPPWRAPPER_DLL_API void ParseMessage(const nim_cpp_wrapper_util::Json::Value& msg_json, IMMessage& message);
583 
584 } // namespace nim
585 
586 #endif //_NIM_SDK_CPP_TALK_HELPER_H_
nim::IMMessage::session_type_
NIMSessionType session_type_
Definition: nim_talk_helper.h:238
nim::MessageSetting::yidun_anti_cheating_
std::string yidun_anti_cheating_
Definition: nim_talk_helper.h:51
nim::IMMessage::third_party_callback_ext_
std::string third_party_callback_ext_
Definition: nim_talk_helper.h:247
nim::IMMessage::status_
NIMMsgLogStatus status_
Definition: nim_talk_helper.h:253
nim::MessageSetting::resend_flag_
BoolStatus resend_flag_
Definition: nim_talk_helper.h:25
nim::MessageSetting::team_msg_ack_sent_
BoolStatus team_msg_ack_sent_
Definition: nim_talk_helper.h:48
nim::IMMessage::readonly_server_id_
int64_t readonly_server_id_
Definition: nim_talk_helper.h:262
nim::IMLocation::description_
std::string description_
Definition: nim_talk_helper.h:449
nim::IMFile::md5_
std::string md5_
Definition: nim_talk_helper.h:379
nim::IMImage::width_
int width_
Definition: nim_talk_helper.h:426
nim::MessageSetting::team_msg_unread_count_
int team_msg_unread_count_
Definition: nim_talk_helper.h:49
nim::IMBotRobot::robot_accid_
std::string robot_accid_
Definition: nim_talk_helper.h:521
nim::MessageSetting::anti_spam_content_
std::string anti_spam_content_
Definition: nim_talk_helper.h:42
nim::BroadcastMessage
Definition: nim_talk_helper.h:545
nim::IMBotRobot::out_msg_
bool out_msg_
Definition: nim_talk_helper.h:520
nim::MessageSetting::is_update_session_
BoolStatus is_update_session_
Definition: nim_talk_helper.h:50
nim::IMImage::height_
int height_
Definition: nim_talk_helper.h:427
nim::IMMessage::local_res_path_
std::string local_res_path_
Definition: nim_talk_helper.h:250
nim::ParseReceiveMessage
NIM_SDK_CPPWRAPPER_DLL_API bool ParseReceiveMessage(const std::string &msg_json, IMMessage &message)
解析消息
nim::IMMessage::feature_
NIMMessageFeature feature_
Definition: nim_talk_helper.h:235
nim::IMFile::msg_attachment_tag_
std::string msg_attachment_tag_
Definition: nim_talk_helper.h:384
nim::MessageSetting::env_config_
std::string env_config_
Definition: nim_talk_helper.h:52
nim::IMAudio::IMAudio
IMAudio()
Definition: nim_talk_helper.h:477
nim::IMBotRobot
波特机器人消息附件
Definition: nim_talk_helper.h:519
nim::MessageSetting::routable_
BoolStatus routable_
Definition: nim_talk_helper.h:32
nim::IMMessage::msg_setting_
MessageSetting msg_setting_
Definition: nim_talk_helper.h:246
nim::IMMessage::ToJsonString
std::string ToJsonString(bool use_to_send) const
组装Json Value字符串
Definition: nim_talk_helper.h:371
nim::IMMessage::timetag_
int64_t timetag_
Definition: nim_talk_helper.h:241
nim::IMMessage::IMMessage
IMMessage()
Definition: nim_talk_helper.h:265
nim::IMMessage::readonly_sender_client_type_
NIMClientType readonly_sender_client_type_
Definition: nim_talk_helper.h:259
nim::IMMessage::ToJsonObject
nim_cpp_wrapper_util::Json::Value ToJsonObject(bool use_to_send) const
组装Json Object
Definition: nim_talk_helper.h:323
nim::IMMessage::sender_accid_
std::string sender_accid_
Definition: nim_talk_helper.h:240
nim::MessageSetting::force_push_content_
std::string force_push_content_
Definition: nim_talk_helper.h:40
nim::MessageSetting::force_push_ids_list_
std::list< std::string > force_push_ids_list_
Definition: nim_talk_helper.h:39
nim::MessageSetting::push_need_badge_
BoolStatus push_need_badge_
Definition: nim_talk_helper.h:30
nim::IMVideo::IMVideo
IMVideo()
Definition: nim_talk_helper.h:499
nim::MessageSetting::local_ext_
std::string local_ext_
Definition: nim_talk_helper.h:37
nim::MessageSetting::client_anti_spam_hitting_
BoolStatus client_anti_spam_hitting_
Definition: nim_talk_helper.h:46
nim::IMMessage::local_res_id_
std::string local_res_id_
Definition: nim_talk_helper.h:252
nim::MessageSetting::anti_apam_using_yidun_
int anti_apam_using_yidun_
Definition: nim_talk_helper.h:44
nim::IMAudio::duration_
int duration_
Definition: nim_talk_helper.h:474
nim::IMMessage::IMMessage
IMMessage(const std::string &json_msg)
Definition: nim_talk_helper.h:277
nim::MessageSetting::push_need_prefix_
BoolStatus push_need_prefix_
Definition: nim_talk_helper.h:31
nim::IMFile::file_extension_
std::string file_extension_
Definition: nim_talk_helper.h:383
nim::IMBotRobot::robot_msg_flag_
std::string robot_msg_flag_
Definition: nim_talk_helper.h:525
nim::IMLocation::ToJsonString
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:462
nim::MessageSetting::anti_apam_biz_id_
std::string anti_apam_biz_id_
Definition: nim_talk_helper.h:43
nim::MessageSetting::anti_spam_enable_
BoolStatus anti_spam_enable_
Definition: nim_talk_helper.h:41
nim::IMFile::size_
int64_t size_
Definition: nim_talk_helper.h:380
nim::IMFile::url_
std::string url_
Definition: nim_talk_helper.h:381
nim::IMVideo::ToJsonString
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:508
nim
namespace nim
nim::IMImage::IMImage
IMImage()
Definition: nim_talk_helper.h:430
nim::IMBotRobot::IMBotRobot
IMBotRobot()
Definition: nim_talk_helper.h:529
nim::IMVideo::height_
int height_
Definition: nim_talk_helper.h:496
nim::IMLocation::latitude_
double latitude_
Definition: nim_talk_helper.h:450
nim::IMBotRobot::ToJsonString
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:536
nim::MessageSetting::roaming_
BoolStatus roaming_
Definition: nim_talk_helper.h:27
nim::IMLocation
位置消息附件
Definition: nim_talk_helper.h:448
nim::IMVideo::width_
int width_
Definition: nim_talk_helper.h:495
nim::IMMessage::receiver_accid_
std::string receiver_accid_
Definition: nim_talk_helper.h:239
nim::IMFile::IMFile
IMFile()
Definition: nim_talk_helper.h:387
nim::IMBotRobot::sent_param_
nim_cpp_wrapper_util::Json::Value sent_param_
Definition: nim_talk_helper.h:522
nim::ParseMessage
NIM_SDK_CPPWRAPPER_DLL_API bool ParseMessage(const std::string &msg_json, IMMessage &message)
解析消息
nim::IMLocation::longitude_
double longitude_
Definition: nim_talk_helper.h:451
nim::IMBotRobot::robot_msg_content_
nim_cpp_wrapper_util::Json::Value robot_msg_content_
Definition: nim_talk_helper.h:526
nim::MessageSetting::ParseMessageSetting
void ParseMessageSetting(const nim_cpp_wrapper_util::Json::Value &message)
从Json Value解析出消息属性设置
Definition: nim_talk_helper.h:146
nim::MessageSetting::self_sync_
BoolStatus self_sync_
Definition: nim_talk_helper.h:28
nim::MessageSetting::is_force_push_
BoolStatus is_force_push_
Definition: nim_talk_helper.h:38
nim::IMMessage::type_
NIMMessageType type_
Definition: nim_talk_helper.h:243
nim::IMMessage::sub_type_
int32_t sub_type_
Definition: nim_talk_helper.h:248
nim::MessageSetting::server_history_saved_
BoolStatus server_history_saved_
Definition: nim_talk_helper.h:26
nim::MessageSetting::team_msg_need_ack_
BoolStatus team_msg_need_ack_
Definition: nim_talk_helper.h:47
nim::IMMessage::readonly_sender_nickname_
std::string readonly_sender_nickname_
Definition: nim_talk_helper.h:261
nim::MessageSetting::ToJsonValue
void ToJsonValue(nim_cpp_wrapper_util::Json::Value &message) const
组装Json Value字符串
Definition: nim_talk_helper.h:82
nim::IMMessage::sub_status_
NIMMsgLogSubStatus sub_status_
Definition: nim_talk_helper.h:254
nim::MessageSetting
消息属性设置
Definition: nim_talk_helper.h:24
nim::IMAudio
语音消息附件
Definition: nim_talk_helper.h:473
nim::MessageSetting::push_payload_
nim_cpp_wrapper_util::Json::Value push_payload_
Definition: nim_talk_helper.h:34
nim::IMMessage::attach_
std::string attach_
Definition: nim_talk_helper.h:244
nim::MessageSetting::need_push_
BoolStatus need_push_
Definition: nim_talk_helper.h:29
nim::IMFile::ToJsonString
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:417
nim::IMFile::display_name_
std::string display_name_
Definition: nim_talk_helper.h:382
nim::IMImage::ToJsonString
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:438
nim::MessageSetting::MessageSetting
MessageSetting()
Definition: nim_talk_helper.h:55
nim::MessageSetting::need_offline_
BoolStatus need_offline_
Definition: nim_talk_helper.h:33
nim::IMMessage::rescode_
NIMResCode rescode_
Definition: nim_talk_helper.h:234
nim::IMVideo::duration_
int duration_
Definition: nim_talk_helper.h:494
nim::IMBotRobot::related_msg_id_
std::string related_msg_id_
Definition: nim_talk_helper.h:524
nim::IMImage
图片消息附件
Definition: nim_talk_helper.h:425
nim_sdk_loader_helper.h
加载 NIM SDK 的帮助类头文件
nim::IMMessage::content_
std::string content_
Definition: nim_talk_helper.h:242
nim::IMFile
文件消息附件
Definition: nim_talk_helper.h:378
nim::IMFile::ToJsonString
std::string ToJsonString(nim_cpp_wrapper_util::Json::Value &attach) const
组装Json Value字符串
Definition: nim_talk_helper.h:396
nim::IMMessage::readonly_sender_device_id_
std::string readonly_sender_device_id_
Definition: nim_talk_helper.h:260
nim::IMMessage::client_msg_id_
std::string client_msg_id_
Definition: nim_talk_helper.h:245
nim::MessageSetting::push_content_
std::string push_content_
Definition: nim_talk_helper.h:35
nim::IMAudio::ToJsonString
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:484
nim::IMLocation::IMLocation
IMLocation()
Definition: nim_talk_helper.h:454
nim::IMVideo
小视频消息附件
Definition: nim_talk_helper.h:493
nim::IMMessage
Definition: nim_talk_helper.h:232
nim::MessageSetting::server_ext_
nim_cpp_wrapper_util::Json::Value server_ext_
Definition: nim_talk_helper.h:36
nim::IMMessage::local_talk_id_
std::string local_talk_id_
Definition: nim_talk_helper.h:251
nim::IMMessageThreadInfo
P2P和群组消息
Definition: nim_talk_helper.h:206