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