NIM PC Cross Platform SDK
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"
21namespace nim {
22
24struct NIM_SDK_CPPWRAPPER_DLL_API MessageSetting {
46 std::string push_content_;
50 std::string local_ext_;
54 std::list<std::string> force_push_ids_list_;
60 std::string anti_spam_content_;
62 std::string anti_apam_biz_id_;
78 std::string env_config_;
80 std::string anti_spam_ext;
82 std::string anti_spam_res;
83
86 : resend_flag_(BS_NOT_INIT)
87 , server_history_saved_(BS_NOT_INIT)
88 , roaming_(BS_NOT_INIT)
89 , self_sync_(BS_NOT_INIT)
90 , need_push_(BS_NOT_INIT)
91 , push_need_badge_(BS_NOT_INIT)
92 , push_need_prefix_(BS_NOT_INIT)
93 , routable_(BS_NOT_INIT)
94 , need_offline_(BS_NOT_INIT)
95 , is_force_push_(BS_NOT_INIT)
96 , anti_spam_enable_(BS_NOT_INIT)
97 , anti_apam_biz_id_("")
98 , anti_apam_using_yidun_(1)
99 , client_anti_spam_hitting_(BS_NOT_INIT)
100 , team_msg_need_ack_(BS_NOT_INIT)
101 , team_msg_ack_sent_(BS_NOT_INIT)
102 , team_msg_unread_count_(-1)
103 , is_update_session_(BS_NOT_INIT)
104 , yidun_anti_cheating_("")
105 , env_config_("") {}
106
113 if (server_history_saved_ != BS_NOT_INIT)
114 message[kNIMMsgKeyHistorySave] = server_history_saved_;
115 if (roaming_ != BS_NOT_INIT)
116 message[kNIMMsgKeyMsgRoaming] = roaming_;
117 if (self_sync_ != BS_NOT_INIT)
118 message[kNIMMsgKeyMsgSync] = self_sync_;
119 if (push_need_badge_ != BS_NOT_INIT)
120 message[kNIMMsgKeyPushNeedBadge] = push_need_badge_;
121 if (need_push_ != BS_NOT_INIT)
122 message[kNIMMsgKeyPushEnable] = need_push_;
123 if (push_need_prefix_ != BS_NOT_INIT)
124 message[kNIMMsgKeyPushNeedPrefix] = push_need_prefix_;
125 if (resend_flag_ != BS_NOT_INIT)
126 message[kNIMMsgKeyResendFlag] = resend_flag_;
127 if (routable_ != BS_NOT_INIT)
128 message[kNIMMsgKeyMsgRoutable] = routable_;
129 if (need_offline_ != BS_NOT_INIT)
130 message[kNIMMsgKeySetMsgOffline] = need_offline_;
131 if (!push_payload_.empty())
132 message[kNIMMsgKeyPushPayload] = GetJsonStringWithNoStyled(push_payload_);
133 if (!push_content_.empty())
134 message[kNIMMsgKeyPushContent] = push_content_;
135 if (!server_ext_.empty())
136 message[kNIMMsgKeyServerExt] = GetJsonStringWithNoStyled(server_ext_);
137 if (!local_ext_.empty())
138 message[kNIMMsgKeyLocalExt] = local_ext_;
139 if (is_force_push_ != BS_NOT_INIT)
140 message[kNIMMsgKeyIsForcePush] = is_force_push_ == BS_TRUE ? 1 : 0;
141 if (!force_push_content_.empty())
142 message[kNIMMsgKeyForcePushContent] = force_push_content_;
143 if (!force_push_ids_list_.empty()) {
144 std::string ids_json;
145 StrListToJsonString(force_push_ids_list_, ids_json);
146 message[kNIMMsgKeyForcePushList] = ids_json;
147 }
148 if (anti_spam_enable_ != BS_NOT_INIT)
149 message[kNIMMsgKeyAntiSpamEnable] = anti_spam_enable_ == BS_TRUE ? 1 : 0;
150 if (!anti_spam_content_.empty())
151 message[kNIMMsgKeyAntiSpamContent] = anti_spam_content_;
152 if (!anti_apam_biz_id_.empty())
153 message[kNIMMsgKeyAntiSpamBizId] = anti_apam_biz_id_;
154 message[kNIMMsgKeyAntiSpamUsingYiDun] = anti_apam_using_yidun_;
155 if (client_anti_spam_hitting_ != BS_NOT_INIT)
156 message[kNIMMsgKeyClientAntiSpam] = client_anti_spam_hitting_;
157 if (team_msg_need_ack_ != BS_NOT_INIT)
158 message[kNIMMsgKeyTeamMsgAck] = team_msg_need_ack_;
159 if (team_msg_ack_sent_ != BS_NOT_INIT)
160 message[kNIMMsgKeyLocalKeyTeamMsgAckSent] = team_msg_ack_sent_;
161 if (team_msg_unread_count_ > -1)
162 message[kNIMMsgKeyLocalKeyTeamMsgUnreadCount] = team_msg_unread_count_;
163 if (is_update_session_ != BS_NOT_INIT)
164 message[kNIMMsgKeyIsUpdateSession] = is_update_session_;
165 if (!yidun_anti_cheating_.empty())
166 message[kNIMMsgKeyAntiCheatingYiDun] = yidun_anti_cheating_;
167 if (!anti_spam_ext.empty())
168 message[kNIMMsgKeyAntiSpamExt] = anti_spam_ext;
169 if (!anti_spam_res.empty())
170 message[kNIMMsgKeyAntiSpamRes] = anti_spam_res;
171 if (!env_config_.empty())
172 message[kNIMMsgKeyEnv] = env_config_;
173 }
174
181 if (message.isMember(kNIMMsgKeyHistorySave))
182 server_history_saved_ = message[kNIMMsgKeyHistorySave].asInt() == 1 ? BS_TRUE : BS_FALSE;
183 if (message.isMember(kNIMMsgKeyMsgRoaming))
184 roaming_ = message[kNIMMsgKeyMsgRoaming].asInt() == 1 ? BS_TRUE : BS_FALSE;
185 if (message.isMember(kNIMMsgKeyMsgSync))
186 self_sync_ = message[kNIMMsgKeyMsgSync].asInt() == 1 ? BS_TRUE : BS_FALSE;
188 push_need_badge_ = message[kNIMMsgKeyPushNeedBadge].asInt() == 1 ? BS_TRUE : BS_FALSE;
189 if (message.isMember(kNIMMsgKeyPushEnable))
190 need_push_ = message[kNIMMsgKeyPushEnable].asInt() == 1 ? BS_TRUE : BS_FALSE;
192 push_need_prefix_ = message[kNIMMsgKeyPushNeedPrefix].asInt() == 1 ? BS_TRUE : BS_FALSE;
193 if (message.isMember(kNIMMsgKeyResendFlag))
194 resend_flag_ = message[kNIMMsgKeyResendFlag].asInt() == 1 ? BS_TRUE : BS_FALSE;
195 if (message.isMember(kNIMMsgKeyMsgRoutable))
196 routable_ = message[kNIMMsgKeyMsgRoutable].asInt() == 1 ? BS_TRUE : BS_FALSE;
198 need_offline_ = message[kNIMMsgKeySetMsgOffline].asInt() == 1 ? BS_TRUE : BS_FALSE;
199 if (message.isMember(kNIMMsgKeyServerExt) && !message[kNIMMsgKeyServerExt].asString().empty())
200 if ((!nim::ParseJsonValue(message[kNIMMsgKeyServerExt].asString(), server_ext_) || !server_ext_.isObject())) {
201 } else {
202 }
203 if (message.isMember(kNIMMsgKeyPushPayload) && !message[kNIMMsgKeyPushPayload].asString().empty())
204 if (!nim::ParseJsonValue(message[kNIMMsgKeyPushPayload].asString(), push_payload_) || !push_payload_.isObject()) {
205 }
206 local_ext_ = message[kNIMMsgKeyLocalExt].asString();
207 push_content_ = message[kNIMMsgKeyPushContent].asString();
208 if (message.isMember(kNIMMsgKeyIsForcePush))
209 is_force_push_ = message[kNIMMsgKeyIsForcePush].asInt() == 1 ? BS_TRUE : BS_FALSE;
210 force_push_content_ = message[kNIMMsgKeyForcePushContent].asString();
211 if (message[kNIMMsgKeyForcePushList].isString()) {
213 if (nim::ParseJsonValue(message[kNIMMsgKeyForcePushList].asString(), values) && values.isArray())
214 JsonStrArrayToList(values, force_push_ids_list_);
215 else {
216 // assert(0);
217 }
218 }
220 anti_spam_enable_ = message[kNIMMsgKeyAntiSpamEnable].asInt() == 1 ? BS_TRUE : BS_FALSE;
221 anti_spam_content_ = message[kNIMMsgKeyAntiSpamContent].asString();
223 client_anti_spam_hitting_ = message[kNIMMsgKeyClientAntiSpam].asInt() == 1 ? BS_TRUE : BS_FALSE;
224 if (message.isMember(kNIMMsgKeyTeamMsgAck))
225 team_msg_need_ack_ = message[kNIMMsgKeyTeamMsgAck].asInt() == 1 ? BS_TRUE : BS_FALSE;
227 team_msg_ack_sent_ = message[kNIMMsgKeyTeamMsgAck].asInt() == 1 ? BS_TRUE : BS_FALSE;
229 team_msg_unread_count_ = message[kNIMMsgKeyLocalKeyTeamMsgUnreadCount].asInt();
231 is_update_session_ = message[kNIMMsgKeyIsUpdateSession].asBool() ? BS_TRUE : BS_FALSE;
233 yidun_anti_cheating_ = message[kNIMMsgKeyAntiCheatingYiDun].asString();
234 if (message.isMember(kNIMMsgKeyAntiSpamExt))
235 anti_spam_ext = message[kNIMMsgKeyAntiSpamExt].asString();
236 if (message.isMember(kNIMMsgKeyAntiSpamRes))
237 anti_spam_res = message[kNIMMsgKeyAntiSpamRes].asString();
238 if (message.isMember(kNIMMsgKeyEnv))
239 env_config_ = message[kNIMMsgKeyEnv].asString();
240 }
241};
242
244struct NIM_SDK_CPPWRAPPER_DLL_API IMMessageThreadInfo {
255
269 : reply_msg_from_account_("")
270 , reply_msg_to_account_("")
271 , reply_msg_time_(0)
272 , reply_msg_id_server_(0)
273 , reply_msg_id_client_("")
274 , thread_msg_from_account_("")
275 , thread_msg_to_account_("")
276 , thread_msg_time_(0)
277 , thread_msg_id_server_(0)
278 , thread_msg_id_client_("")
279 , deleted_(0) {}
280};
281struct NIM_SDK_CPPWRAPPER_DLL_API IMMessage {
282public:
287
288public:
292 std::string receiver_accid_;
294 std::string sender_accid_;
296 int64_t timetag_;
298 std::string content_;
302 std::string attach_;
304 std::string client_msg_id_;
310 int32_t sub_type_{0};
311
312public:
314 std::string local_res_path_;
316 std::string local_talk_id_;
318 std::string local_res_id_;
323
324public:
325 IMMessageThreadInfo thread_info_;
326
327public:
336
339 : rescode_((NIMResCode)0)
340 , feature_(kNIMMessageFeatureDefault)
341 , readonly_sender_client_type_(kNIMClientTypeDefault)
342 , readonly_server_id_(0)
343 , session_type_(kNIMSessionTypeP2P)
344 , timetag_(0)
346 , status_(nim::kNIMMsgLogStatusNone)
347 , sub_status_(nim::kNIMMsgLogSubStatusNone) {}
348
350 IMMessage(const std::string& json_msg)
351 : rescode_((NIMResCode)0)
352 , feature_(kNIMMessageFeatureDefault)
353 , readonly_sender_client_type_(kNIMClientTypeDefault)
354 , readonly_server_id_(0)
355 , session_type_(kNIMSessionTypeP2P)
356 , timetag_(0)
358 , status_(nim::kNIMMsgLogStatusNone)
359 , sub_status_(nim::kNIMMsgLogSubStatusNone) {
361 if (nim::ParseJsonValue(json_msg, values) && values.isObject()) {
362 session_type_ = (NIMSessionType)values[kNIMMsgKeyToType].asUInt();
363 receiver_accid_ = values[kNIMMsgKeyToAccount].asString();
364 sender_accid_ = values[kNIMMsgKeyFromAccount].asString();
365 readonly_sender_client_type_ = (NIMClientType)values[kNIMMsgKeyFromClientType].asUInt();
366 readonly_sender_device_id_ = values[kNIMMsgKeyFromDeviceId].asString();
367 readonly_sender_nickname_ = values[kNIMMsgKeyFromNick].asString();
368 timetag_ = values[kNIMMsgKeyTime].asUInt64();
369
370 type_ = (NIMMessageType)values[kNIMMsgKeyType].asUInt();
371 content_ = values[kNIMMsgKeyBody].asString();
372 attach_ = values[kNIMMsgKeyAttach].asString();
373 client_msg_id_ = values[kNIMMsgKeyClientMsgid].asString();
374 readonly_server_id_ = values[kNIMMsgKeyServerMsgid].asUInt64();
375
376 local_res_path_ = values[kNIMMsgKeyLocalFilePath].asString();
377 local_talk_id_ = values[kNIMMsgKeyLocalTalkId].asString();
378 local_res_id_ = values[kNIMMsgKeyLocalResId].asString();
379 status_ = (NIMMsgLogStatus)values[kNIMMsgKeyLocalLogStatus].asUInt();
380 sub_status_ = (NIMMsgLogSubStatus)values[kNIMMsgKeyLocalLogSubStatus].asUInt();
381
382 msg_setting_.ParseMessageSetting(values);
383
384 // v7.8 <--
385 third_party_callback_ext_ = values[kNIMMsgKeyThirdPartyCBEXT].asString();
386 sub_type_ = values[kNIMMsgKeySubType].asInt();
387 // --> v7.8
388 }
389 }
390
397 values[kNIMMsgKeyToType] = session_type_;
398 values[kNIMMsgKeyToAccount] = receiver_accid_;
399 values[kNIMMsgKeyFromAccount] = sender_accid_;
400 values[kNIMMsgKeyTime] = timetag_;
401 values[kNIMMsgKeyType] = type_;
402 values[kNIMMsgKeyBody] = content_;
403 values[kNIMMsgKeyAttach] = attach_;
404 values[kNIMMsgKeyClientMsgid] = client_msg_id_;
405 values[kNIMMsgKeyLocalFilePath] = local_res_path_;
406 values[kNIMMsgKeyLocalTalkId] = local_talk_id_;
407 values[kNIMMsgKeyLocalResId] = local_res_id_;
408 values[kNIMMsgKeyLocalLogStatus] = status_;
409 values[kNIMMsgKeyLocalLogSubStatus] = sub_status_;
410 values[kNIMMsgKeySubType] = sub_type_;
411 msg_setting_.ToJsonValue(values);
412
413 if (!use_to_send) {
414 values[kNIMMsgKeyFromClientType] = readonly_sender_client_type_;
415 values[kNIMMsgKeyFromDeviceId] = readonly_sender_device_id_;
416 values[kNIMMsgKeyFromNick] = readonly_sender_nickname_;
417 values[kNIMMsgKeyServerMsgid] = readonly_server_id_;
418 values[kNIMMsgKeyThirdPartyCBEXT] = third_party_callback_ext_;
419 }
420 // thread
421 {
427
433
434 values[kNIMMsgKeyThreadInfo][kNIMMsgKeyDeleted] = thread_info_.deleted_;
435 }
436 return values;
437 }
438
443 std::string ToJsonString(bool use_to_send) const {
444 nim_cpp_wrapper_util::Json::Value values = ToJsonObject(use_to_send);
445 return GetJsonStringWithNoStyled(values);
446 }
447};
448
450struct NIM_SDK_CPPWRAPPER_DLL_API IMFile {
452 std::string md5_;
454 int64_t size_;
456 std::string url_;
458 std::string display_name_;
460 std::string file_extension_;
465 : size_(0)
466 , msg_attachment_tag_(kNIMNosDefaultTagIM) {}
467
474 // 以下客户端可以选填
475 if (!display_name_.empty())
476 attach[kNIMFileMsgKeyDisplayName] = display_name_;
477 if (!file_extension_.empty())
478 attach[kNIMFileMsgKeyExt] = file_extension_;
479 if (!md5_.empty())
480 attach[kNIMFileMsgKeyMd5] = md5_;
481 if (size_ > 0)
482 attach[kNIMFileMsgKeySize] = size_;
483 if (!url_.empty())
484 attach[kNIMMsgAttachKeyUrl] = url_;
485 if (!msg_attachment_tag_.empty())
486 attach[kNIMMsgAttachKeyTag] = msg_attachment_tag_;
487 return GetJsonStringWithNoStyled(attach);
488 }
489
494 std::string ToJsonString() const {
496 attach[kNIMFileMsgKeyDisplayName] = display_name_;
497 return ToJsonString(attach);
498 }
499};
500
502struct NIM_SDK_CPPWRAPPER_DLL_API IMImage : IMFile {
507
510 : width_(0)
511 , height_(0) {}
512
517 std::string ToJsonString() const {
519 attach[kNIMImgMsgKeyWidth] = width_;
520 attach[kNIMImgMsgKeyHeight] = height_;
521
522 return IMFile::ToJsonString(attach); // remove the Visual C++ __super keyword.
523 }
524};
525
527struct NIM_SDK_CPPWRAPPER_DLL_API IMLocation {
529 std::string description_;
531 double latitude_;
534
537 : latitude_(0)
538 , longitude_(0) {}
539
544 std::string ToJsonString() const {
546 attach[kNIMLocationMsgKeyTitle] = description_;
547 attach[kNIMLocationMsgKeyLatitude] = latitude_;
548 attach[kNIMLocationMsgKeyLongitude] = longitude_;
549
550 return GetJsonStringWithNoStyled(attach);
551 }
552};
553
555struct NIM_SDK_CPPWRAPPER_DLL_API IMAudio : IMFile {
558
561 : duration_(0) {}
562
567 std::string ToJsonString() const {
569 attach[kNIMAudioMsgKeyDuration] = duration_;
570
571 return IMFile::ToJsonString(attach); // remove the Visual C++ __super keyword.
572 }
573};
574
576struct NIM_SDK_CPPWRAPPER_DLL_API IMVideo : IMFile {
583
586 : duration_(0)
587 , width_(0)
588 , height_(0) {}
589
594 std::string ToJsonString() const {
596 attach[kNIMVideoMsgKeyWidth] = width_;
597 attach[kNIMVideoMsgKeyHeight] = height_;
598 attach[kNIMVideoMsgKeyDuration] = duration_;
599
600 return IMFile::ToJsonString(attach); // remove the Visual C++ __super keyword.
601 }
602};
603
605struct NIM_SDK_CPPWRAPPER_DLL_API IMBotRobot {
609 std::string robot_accid_;
612
614 std::string related_msg_id_;
616 std::string robot_msg_flag_;
619
622 : out_msg_(false) {}
623
628 std::string ToJsonString() const {
630 attach[kNIMBotRobotMsgKeyRobotID] = robot_accid_;
631 attach[kNIMBotRobotSentMsgKeyParam] = sent_param_;
632
633 return GetJsonStringWithNoStyled(attach);
634 }
635};
636
638struct NIM_SDK_CPPWRAPPER_DLL_API BroadcastMessage {
639 std::string body_;
640 int64_t time_;
641 int64_t id_;
642 std::string from_id_;
643};
644
651NIM_SDK_CPPWRAPPER_DLL_API bool ParseMessage(const std::string& msg_json, IMMessage& message);
652
659NIM_SDK_CPPWRAPPER_DLL_API bool ParseReceiveMessage(const std::string& msg_json, IMMessage& message);
660
667NIM_SDK_CPPWRAPPER_DLL_API void ParseReceiveMessage(const nim_cpp_wrapper_util::Json::Value& msg_json_value, IMMessage& message);
668
675NIM_SDK_CPPWRAPPER_DLL_API void ParseMessage(const nim_cpp_wrapper_util::Json::Value& msg_json, IMMessage& message);
676
677} // namespace nim
678
679#endif //_NIM_SDK_CPP_TALK_HELPER_H_
Represents a JSON value.
Definition: value.h:196
bool isMember(const char *key) const
Definition: json_value.cpp:1241
bool empty() const
Return true if empty array, empty object, or null; otherwise, false.
Definition: json_value.cpp:908
String asString() const
Embedded zeroes are possible.
Definition: json_value.cpp:632
namespace nim
bool ParseMessage(const std::string &msg_json, IMMessage &message)
解析消息
Definition: nim_talk_helper.cpp:11
bool ParseJsonValue(const std::string &content, nim_cpp_wrapper_util::Json::Value &values)
解析JsonString
Definition: nim_json_util.cpp:70
bool StrListToJsonString(const std::list< std::string > &list, std::string &out)
将一个string类型的list组装成一个Json Array
Definition: nim_json_util.cpp:12
bool ParseReceiveMessage(const std::string &msg_json, IMMessage &message)
解析消息
Definition: nim_talk_helper.cpp:20
bool JsonStrArrayToList(const nim_cpp_wrapper_util::Json::Value &array_str, std::list< std::string > &out)
将一个string类型的Json Array解析成一个string类型的list
Definition: nim_json_util.cpp:30
std::string GetJsonStringWithNoStyled(const nim_cpp_wrapper_util::Json::Value &values)
获得非格式化的Json string,传入SDK的json string格式要求为非格式化的,如果是格式化的json string可能会影响功能
Definition: nim_json_util.cpp:89
NIMResCode
Definition: nim_chatroom_res_code_def.h:15
NIMClientType
Definition: nim_client_def.h:113
@ kNIMClientTypeDefault
Default, unset.
Definition: nim_client_def.h:115
NIM 公共数据类型定义总的包含文件
JSON辅助方法
NIMMsgLogStatus
Definition: nim_msglog_def.h:312
@ kNIMMsgLogStatusNone
默认,不能当查询条件,意义太多
Definition: nim_msglog_def.h:314
NIMMessageType
Definition: nim_msglog_def.h:269
@ kNIMMessageTypeUnknown
未知类型消息,本地使用,发送时勿使用,作为默认值
Definition: nim_msglog_def.h:294
NIMMsgLogSubStatus
Definition: nim_msglog_def.h:434
@ kNIMMsgLogSubStatusNone
默认状态
Definition: nim_msglog_def.h:436
NIMMessageFeature
Definition: nim_msglog_def.h:298
@ kNIMMessageFeatureDefault
默认
Definition: nim_msglog_def.h:300
static const char * kNIMNosDefaultTagIM
string im消息类文件上传tag 如图片、文件、音视频消息等, 可以通过 nim_nos_init_tags修改资源的过期时间
Definition: nim_nos_def.h:203
定义导出宏
加载 NIM SDK 的帮助类头文件
BoolStatus
Definition: nim_sdk_util.h:22
@ BS_TRUE
true
Definition: nim_sdk_util.h:28
@ BS_NOT_INIT
未初始化
Definition: nim_sdk_util.h:24
@ BS_FALSE
false
Definition: nim_sdk_util.h:26
NIMSessionType
Definition: nim_session_def.h:16
@ kNIMSessionTypeP2P
个人,即点对点
Definition: nim_session_def.h:18
static const char * kNIMMsgKeyAttach
string,消息多媒体资源参数,不同类型多媒体参数不同,发送非多媒体消息时不需要填写,如需使用json string,必须为可以解析为json的非格式化的字符串
Definition: nim_talk_def.h:156
static const char * kNIMLocationMsgKeyLatitude
double,纬度
Definition: nim_talk_def.h:379
static const char * kNIMMsgKeyFromDeviceId
string,消息发送方设备id,服务器填写,发送方不需要填写
Definition: nim_talk_def.h:146
static const char * kNIMMsgKeyReplyMsgToAccount
(可选)string,从属thread_info节点,被回复消息的消息接受者,群的话是tid
Definition: nim_talk_def.h:220
static const char * kNIMMsgKeyThreadInfo
(可选) json object,被回复消息的消息发送者
Definition: nim_talk_def.h:216
static const char * kNIMMsgKeyAntiSpamUsingYiDun
int, (可选) 单条消息是否使用易盾反垃圾 0:(在开通易盾的情况下)不过易盾反垃圾而是通用反垃圾 其他都是按照原来的规则
Definition: nim_talk_def.h:201
static const char * kNIMMsgKeyReplyMsgIdClient
(可选)string,从属thread_info节点,被回复消息的消息ID)clientId)
Definition: nim_talk_def.h:226
static const char * kNIMMsgKeyToType
int,会话类型(NIMSessionType)
Definition: nim_talk_def.h:138
static const char * kNIMMsgKeyThreadMsgIdServer
(可选)long,从属thread_info节点,thread消息的消息ID)serverId)
Definition: nim_talk_def.h:234
static const char * kNIMMsgKeyIsForcePush
int,(可选)群组消息是否强推,0:不强推, 1:强推,属性只针对群组消息强推列表
Definition: nim_talk_def.h:190
static const char * kNIMMsgKeyLocalTalkId
string,会话id,发送方选填,接收方收到的是消息发送方id
Definition: nim_talk_def.h:257
static const char * kNIMMsgKeyDeleted
Definition: nim_talk_def.h:239
static const char * kNIMMsgKeyAntiCheatingYiDun
(可选)String, 易盾反垃圾增强反作弊专属字段, 限制json,长度限制1024
Definition: nim_talk_def.h:207
static const char * kNIMMsgKeyClientAntiSpam
int, (可选) 是否命中客户端反垃圾,命中:1 未命中:0 或者不填写
Definition: nim_talk_def.h:197
static const char * kNIMMsgKeyBody
string,消息正文,长度限制:5000字符
Definition: nim_talk_def.h:154
static const char * kNIMMsgKeyClientMsgid
string,客户端消息id
Definition: nim_talk_def.h:158
static const char * kNIMLocationMsgKeyLongitude
double,经度
Definition: nim_talk_def.h:381
static const char * kNIMMsgKeyType
int,消息类型(NIMMessageType)
Definition: nim_talk_def.h:152
static const char * kNIMFileMsgKeyDisplayName
string,用于显示的文件名,发送方选填,默认文件名
Definition: nim_talk_def.h:368
static const char * kNIMMsgKeyLocalKeyTeamMsgUnreadCount
int, 群消息未读数
Definition: nim_talk_def.h:253
static const char * kNIMMsgKeyLocalExt
string,只维护在本地的扩展字段,必须为可以解析为json的非格式化的字符串
Definition: nim_talk_def.h:265
static const char * kNIMMsgKeyAntiSpamBizId
string, (可选)用户配置的对某些单条消息另外的反垃圾的业务ID
Definition: nim_talk_def.h:199
static const char * kNIMMsgKeyTeamMsgAck
(可选)int, 群消息是否需要已读业务,0:不需要,1:需要
Definition: nim_talk_def.h:203
static const char * kNIMMsgKeyMsgRoutable
int,(可选)该消息是否抄送,0:不支持,1:支持,默认按照app的路由开关
Definition: nim_talk_def.h:182
static const char * kNIMMsgKeyReplyMsgFromAccount
(可选)string,从属thread_info节点,被回复消息的消息发送者
Definition: nim_talk_def.h:218
static const char * kNIMMsgKeyForcePushList
string,(可选)群组消息强推列表,推送指定账号id string array json, 如果推送全员不填
Definition: nim_talk_def.h:186
static const char * kNIMMsgKeyServerExt
string,(可选)自定义扩展字段,必须为可以解析为json的非格式化的字符串,长度限制1024
Definition: nim_talk_def.h:172
static const char * kNIMMsgKeySetMsgOffline
int,(可选)消息是否要存离线,0:不需要, 1:需要,默认1
Definition: nim_talk_def.h:184
static const char * kNIMMsgKeyMsgSync
int,(可选)该消息是否支持发送者多端同步,可选,0:不支持,1:支持, 默认1
Definition: nim_talk_def.h:168
static const char * kNIMBotRobotMsgKeyRobotID
string,机器人云信ID
Definition: nim_talk_def.h:390
static const char * kNIMVideoMsgKeyDuration
int,短视频资源时间长度(毫秒),发送方必填
Definition: nim_talk_def.h:349
static const char * kNIMFileMsgKeyMd5
string,资源MD5,发送方选填
Definition: nim_talk_def.h:364
static const char * kNIMMsgKeyFromClientType
int,消息发送方客户端类型(NIMClientType),服务器填写,发送方不需要填写
Definition: nim_talk_def.h:144
static const char * kNIMVideoMsgKeyHeight
int,短视频画面高度,发送方必填
Definition: nim_talk_def.h:353
static const char * kNIMVideoMsgKeyWidth
int,短视频画面宽度,发送方必填
Definition: nim_talk_def.h:351
static const char * kNIMMsgKeyFromAccount
string,消息发送方id,服务器填写,发送方不需要填写
Definition: nim_talk_def.h:142
static const char * kNIMMsgKeyIsUpdateSession
(可选)bool, 消息是否需要刷新到session服务,false:否,true:是;只有消息存离线的情况下,才会判断该参数,缺省:true
Definition: nim_talk_def.h:205
static const char * kNIMMsgKeyServerMsgid
long,服务器端消息id
Definition: nim_talk_def.h:160
static const char * kNIMImgMsgKeyHeight
int,图片高度,发送方必填
Definition: nim_talk_def.h:313
static const char * kNIMMsgKeyAntiSpamEnable
int, 是否需要过易盾反垃圾, 0:不需要,1:需要, 默认0
Definition: nim_talk_def.h:192
static const char * kNIMMsgKeyFromNick
string,消息发送方昵称,服务器填写,发送方不需要填写
Definition: nim_talk_def.h:148
static const char * kNIMMsgKeyMsgRoaming
int,(可选)该消息是否支持漫游,可选,0:不支持,1:支持, 默认1
Definition: nim_talk_def.h:166
static const char * kNIMMsgKeyLocalFilePath
string,多媒体消息资源本地绝对路径,SDK本地维护,发送多媒体消息时必填
Definition: nim_talk_def.h:255
static const char * kNIMMsgKeyPushNeedPrefix
int,(可选)推送是否需要前缀,0:不需要,1:需要,默认1
Definition: nim_talk_def.h:180
static const char * kNIMLocationMsgKeyTitle
string,位置信息
Definition: nim_talk_def.h:383
static const char * kNIMMsgKeyReplyMsgIdServer
(可选)long,从属thread_info节点,被回复消息的消息ID)serverId)
Definition: nim_talk_def.h:224
static const char * kNIMMsgKeyThreadMsgTime
(可选)long,从属thread_info节点,thread消息的消息发送时间
Definition: nim_talk_def.h:232
static const char * kNIMMsgKeyResendFlag
int,消息重发标记位,第一次发送0,重发1
Definition: nim_talk_def.h:162
static const char * kNIMFileMsgKeySize
long,资源大小(KB),发送方选填
Definition: nim_talk_def.h:366
static const char * kNIMMsgKeyLocalResId
string,多媒体资源id,发送方选填,接收方收到的是客户端消息id
Definition: nim_talk_def.h:259
static const char * kNIMMsgKeyLocalKeyTeamMsgAckSent
bool 是否已经发送群消息已读回执
Definition: nim_talk_def.h:251
static const char * kNIMMsgKeyThreadMsgIdClient
(可选)string,从属thread_info节点,thread消息的消息ID)clientId)
Definition: nim_talk_def.h:236
static const char * kNIMMsgKeyToAccount
string,消息接收方id,给自己发送消息时填写自己id
Definition: nim_talk_def.h:140
static const char * kNIMMsgKeyLocalLogSubStatus
int,消息二级状态(NIMMsgLogSubStatus)
Definition: nim_talk_def.h:263
static const char * kNIMImgMsgKeyWidth
int,图片宽度,发送方必填
Definition: nim_talk_def.h:311
static const char * kNIMAudioMsgKeyDuration
int,语音资源时间长度(毫秒),发送方必填
Definition: nim_talk_def.h:330
static const char * kNIMMsgKeyPushNeedBadge
int,(可选)推送是否要做消息计数(角标),0:不需要,1:需要,默认1
Definition: nim_talk_def.h:170
static const char * kNIMMsgKeyThreadMsgFromAccount
(可选)string,从属thread_info节点,thread消息的消息发送者
Definition: nim_talk_def.h:228
static const char * kNIMMsgKeyPushEnable
int,(可选)是否需要推送, 0:不需要,1:需要,默认1,aos在收到0是不要模拟本地推送
Definition: nim_talk_def.h:178
static const char * kNIMMsgKeyForcePushContent
string,(可选)群组消息强推文本
Definition: nim_talk_def.h:188
static const char * kNIMBotRobotSentMsgKeyParam
json string,给机器人发送时需要填的字段,字段内容定义可见Demo源码或参考波特开发文档
Definition: nim_talk_def.h:392
static const char * kNIMMsgKeyAntiSpamContent
Definition: nim_talk_def.h:195
static const char * kNIMMsgKeyTime
long,消息时间戳(毫秒)
Definition: nim_talk_def.h:150
static const char * kNIMMsgAttachKeyUrl
long,资源URL, 发送方不需要填写
Definition: nim_talk_def.h:294
static const char * kNIMMsgKeyPushContent
string,(可选)自定义推送文案,长度限制200字节
Definition: nim_talk_def.h:176
static const char * kNIMMsgKeyThreadMsgToAccount
(可选)string,t从属thread_info节点,hread消息的消息接受者,群的话是tid
Definition: nim_talk_def.h:230
static const char * kNIMMsgKeyReplyMsgTime
(可选)long,从属thread_info节点,被回复消息的消息发送时间
Definition: nim_talk_def.h:222
static const char * kNIMMsgKeyPushPayload
string,(可选)第三方自定义的推送属性,必须为可以解析为json的非格式化的字符串,长度2048
Definition: nim_talk_def.h:174
static const char * kNIMMsgKeyLocalLogStatus
int,消息状态(NIMMsgLogStatus)
Definition: nim_talk_def.h:261
static const char * kNIMMsgKeyHistorySave
int,(可选)该消息是否存储云端历史,可选,0:不支持,1:支持, 默认1
Definition: nim_talk_def.h:164
static const char * kNIMMsgAttachKeyTag
string, (可选)发送含有附件的消息时使用的场景标签(可参见nos删除策略) ,Audio Image Video File 或者可以被SDK解析到本地文件路径的自定义消息
Definition: nim_talk_def.h:300
static const char * kNIMMsgKeySubType
(可选)int,消息的子类型,客户端定义,服务器透传
Definition: nim_talk_def.h:244
static const char * kNIMMsgKeyAntiSpamExt
(可选)String, 易盾反垃圾扩展字段,限制json,长度限制1024
Definition: nim_talk_def.h:209
static const char * kNIMMsgKeyThirdPartyCBEXT
(可选)string第三方回调回来的自定义扩展字段
Definition: nim_talk_def.h:242
static const char * kNIMFileMsgKeyExt
string,资源扩展名,不包括符号'.',发送方若选填需要保证资源本地路径包含扩展名
Definition: nim_talk_def.h:372
static const char * kNIMMsgKeyAntiSpamRes
String, 易盾反垃圾返回的结果字段
Definition: nim_talk_def.h:211
Definition: nim_talk_helper.h:638
语音消息附件
Definition: nim_talk_helper.h:555
int duration_
语音时长
Definition: nim_talk_helper.h:557
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:567
IMAudio()
Definition: nim_talk_helper.h:560
波特机器人消息附件
Definition: nim_talk_helper.h:605
std::string related_msg_id_
机器人回复时带的字段,表示该条回复相关联的消息ID
Definition: nim_talk_helper.h:614
nim_cpp_wrapper_util::Json::Value robot_msg_content_
机器人回复时带的字段,表示该条回复内容,字段内容定义可见Demo源码或参考波特开发文档
Definition: nim_talk_helper.h:618
bool out_msg_
是否为机器人回复,是:true,不是:false,默认false
Definition: nim_talk_helper.h:607
nim_cpp_wrapper_util::Json::Value sent_param_
给机器人发送时需要填的字段,字段内容定义可见Demo源码或参考波特开发文档
Definition: nim_talk_helper.h:611
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:628
IMBotRobot()
Definition: nim_talk_helper.h:621
std::string robot_accid_
机器人云信ID
Definition: nim_talk_helper.h:609
std::string robot_msg_flag_
机器人回复时带的字段,表示该条回复类型,类型定义可见Demo源码或参考波特开发文档
Definition: nim_talk_helper.h:616
文件消息附件
Definition: nim_talk_helper.h:450
std::string md5_
文件内容MD5
Definition: nim_talk_helper.h:452
std::string display_name_
用于显示的文件名称
Definition: nim_talk_helper.h:458
IMFile()
Definition: nim_talk_helper.h:464
std::string url_
上传云端后得到的文件下载地址
Definition: nim_talk_helper.h:456
std::string file_extension_
文件扩展名
Definition: nim_talk_helper.h:460
std::string ToJsonString(nim_cpp_wrapper_util::Json::Value &attach) const
组装Json Value字符串
Definition: nim_talk_helper.h:473
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:494
int64_t size_
文件大小
Definition: nim_talk_helper.h:454
std::string msg_attachment_tag_
string, (可选)发送含有附件的消息时使用的场景标签(可参见nos删除策略) Audio Image Video File或者可以被SDK解析到本地文件路径的自定义消息
Definition: nim_talk_helper.h:462
图片消息附件
Definition: nim_talk_helper.h:502
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:517
int height_
图片高度
Definition: nim_talk_helper.h:506
IMImage()
Definition: nim_talk_helper.h:509
int width_
图片宽度
Definition: nim_talk_helper.h:504
位置消息附件
Definition: nim_talk_helper.h:527
double latitude_
位置纬度
Definition: nim_talk_helper.h:531
double longitude_
位置经度
Definition: nim_talk_helper.h:533
std::string description_
位置描述内容
Definition: nim_talk_helper.h:529
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:544
IMLocation()
Definition: nim_talk_helper.h:536
Definition: nim_talk_helper.h:281
std::string local_res_path_
媒体文件本地绝对路径(客户端)
Definition: nim_talk_helper.h:314
std::string ToJsonString(bool use_to_send) const
组装Json Value字符串
Definition: nim_talk_helper.h:443
NIMSessionType session_type_
会话类型
Definition: nim_talk_helper.h:290
NIMMessageFeature feature_
消息属性
Definition: nim_talk_helper.h:286
MessageSetting msg_setting_
消息属性设置
Definition: nim_talk_helper.h:306
IMMessage(const std::string &json_msg)
Definition: nim_talk_helper.h:350
std::string readonly_sender_device_id_
发送者客户端设备ID(只读)
Definition: nim_talk_helper.h:331
NIMClientType readonly_sender_client_type_
发送者客户端类型(只读)
Definition: nim_talk_helper.h:329
std::string client_msg_id_
消息ID(客户端)
Definition: nim_talk_helper.h:304
std::string receiver_accid_
接收者ID
Definition: nim_talk_helper.h:292
IMMessage()
Definition: nim_talk_helper.h:338
NIMResCode rescode_
错误码
Definition: nim_talk_helper.h:284
NIMMsgLogStatus status_
消息状态(客户端)
Definition: nim_talk_helper.h:320
std::string local_talk_id_
会话ID(客户端)
Definition: nim_talk_helper.h:316
nim_cpp_wrapper_util::Json::Value ToJsonObject(bool use_to_send) const
组装Json Object
Definition: nim_talk_helper.h:395
std::string readonly_sender_nickname_
发送者昵称(只读)
Definition: nim_talk_helper.h:333
NIMMsgLogSubStatus sub_status_
消息子状态(客户端)
Definition: nim_talk_helper.h:322
NIMMessageType type_
消息类型
Definition: nim_talk_helper.h:300
std::string attach_
消息附件 ,长度限制10000
Definition: nim_talk_helper.h:302
int64_t readonly_server_id_
消息ID(服务器,只读)
Definition: nim_talk_helper.h:335
int64_t timetag_
消息时间戳(毫秒)
Definition: nim_talk_helper.h:296
std::string local_res_id_
媒体文件ID(客户端)
Definition: nim_talk_helper.h:318
std::string content_
消息内容,长度限制10000
Definition: nim_talk_helper.h:298
std::string third_party_callback_ext_
第三方回调回来的自定义扩展字段 v7.8添加
Definition: nim_talk_helper.h:308
std::string sender_accid_
发送者ID
Definition: nim_talk_helper.h:294
P2P和群组消息
Definition: nim_talk_helper.h:244
std::string thread_msg_from_account_
thread消息的消息发送者
Definition: nim_talk_helper.h:257
uint64_t thread_msg_time_
thread消息的消息发送时间
Definition: nim_talk_helper.h:261
uint64_t thread_msg_id_server_
thread消息的消息ID(serverId)
Definition: nim_talk_helper.h:263
std::string thread_msg_id_client_
thread消息的消息ID(clientId)
Definition: nim_talk_helper.h:265
std::string reply_msg_from_account_
被回复消息的消息发送者
Definition: nim_talk_helper.h:246
std::string thread_msg_to_account_
thread消息的消息接受者,群的话是tid
Definition: nim_talk_helper.h:259
uint64_t reply_msg_time_
被回复消息的消息发送时间
Definition: nim_talk_helper.h:250
uint64_t reply_msg_id_server_
被回复消息的消息ID(serverId)
Definition: nim_talk_helper.h:252
int deleted_
消息是否已经被删除(可能是撤回,也可能是单向删除),查询thread消息历史时可能会有这个字段,大于0表示已经删除(目前撤回和单向删除都是1,未来可能区分)
Definition: nim_talk_helper.h:267
std::string reply_msg_id_client_
被回复消息的消息ID(clientId)
Definition: nim_talk_helper.h:254
std::string reply_msg_to_account_
被回复消息的消息接受者,群的话是tid
Definition: nim_talk_helper.h:248
小视频消息附件
Definition: nim_talk_helper.h:576
std::string ToJsonString() const
组装Json Value字符串
Definition: nim_talk_helper.h:594
int height_
视频画面高度
Definition: nim_talk_helper.h:582
int duration_
视频时长
Definition: nim_talk_helper.h:578
int width_
视频画面宽度
Definition: nim_talk_helper.h:580
IMVideo()
Definition: nim_talk_helper.h:585
消息属性设置
Definition: nim_talk_helper.h:24
nim_cpp_wrapper_util::Json::Value push_payload_
第三方自定义的推送属性,长度2048
Definition: nim_talk_helper.h:44
std::string anti_spam_ext
(可选)String, 易盾反垃圾扩展字段,限制 json,长度限制 1024
Definition: nim_talk_helper.h:80
std::string anti_apam_biz_id_
(可选)用户配置的对某些单条消息另外的反垃圾的业务ID
Definition: nim_talk_helper.h:62
void ParseMessageSetting(const nim_cpp_wrapper_util::Json::Value &message)
从Json Value解析出消息属性设置
Definition: nim_talk_helper.h:180
BoolStatus team_msg_need_ack_
群消息是否需要已读业务,0:不需要,1:需要
Definition: nim_talk_helper.h:68
std::string force_push_content_
群组消息强推文本
Definition: nim_talk_helper.h:56
BoolStatus push_need_prefix_
需要推送昵称
Definition: nim_talk_helper.h:38
BoolStatus is_force_push_
群组消息强推开关,强推全员设置true并强推列表为空
Definition: nim_talk_helper.h:52
int anti_apam_using_yidun_
int, (可选) 单条消息是否使用易盾反垃圾 0:(在开通易盾的情况下)不过易盾反垃圾而是通用反垃圾 其他都是按照原来的规则
Definition: nim_talk_helper.h:64
BoolStatus client_anti_spam_hitting_
(可选) 是否命中客户端反垃圾
Definition: nim_talk_helper.h:66
std::string yidun_anti_cheating_
(可选)String, 易盾反垃圾增强反作弊专属字段, 限制json,长度限制1024
Definition: nim_talk_helper.h:76
std::string push_content_
自定义推送文案,长度限制200字节
Definition: nim_talk_helper.h:46
BoolStatus anti_spam_enable_
是否需要过易盾反垃圾
Definition: nim_talk_helper.h:58
std::string anti_spam_res
String, 易盾反垃圾返回的结果字段
Definition: nim_talk_helper.h:82
int team_msg_unread_count_
群消息未读数
Definition: nim_talk_helper.h:72
BoolStatus self_sync_
该消息是否支持发送者多端同步
Definition: nim_talk_helper.h:32
BoolStatus is_update_session_
(可选) 消息是否需要刷新到session服务,0:否,1:是;只有消息存离线的情况下,才会判断该参数,缺省:1
Definition: nim_talk_helper.h:74
BoolStatus routable_
是否要抄送
Definition: nim_talk_helper.h:40
BoolStatus push_need_badge_
是否要做消息计数
Definition: nim_talk_helper.h:36
std::string env_config_
(可选)String, 环境变量,用于指向不同的抄送、第三方回调等配置(于8.0.0添加)
Definition: nim_talk_helper.h:78
BoolStatus roaming_
该消息是否支持漫游
Definition: nim_talk_helper.h:30
void ToJsonValue(nim_cpp_wrapper_util::Json::Value &message) const
组装Json Value字符串
Definition: nim_talk_helper.h:112
std::list< std::string > force_push_ids_list_
群组消息强推列表
Definition: nim_talk_helper.h:54
BoolStatus server_history_saved_
该消息是否存储云端历史
Definition: nim_talk_helper.h:28
std::string local_ext_
本地扩展字段, 格式不限,长度限制1024
Definition: nim_talk_helper.h:50
std::string anti_spam_content_
(可选)开发者自定义的反垃圾字段,长度限制5000
Definition: nim_talk_helper.h:60
BoolStatus need_offline_
是否支持离线消息
Definition: nim_talk_helper.h:42
BoolStatus need_push_
是否需要推送
Definition: nim_talk_helper.h:34
MessageSetting()
Definition: nim_talk_helper.h:85
BoolStatus resend_flag_
该消息是否为重发状态
Definition: nim_talk_helper.h:26
BoolStatus team_msg_ack_sent_
是否已经发送群消息已读回执
Definition: nim_talk_helper.h:70
nim_cpp_wrapper_util::Json::Value server_ext_
第三方扩展字段, 长度限制1024
Definition: nim_talk_helper.h:48