NIM PC Cross Platform SDK
nim_cpp_talk.h
Go to the documentation of this file.
1
7#ifndef _NIM_SDK_CPP_TALK_H_
8#define _NIM_SDK_CPP_TALK_H_
9
10#include <functional>
11#include <list>
12#include <string>
20namespace nim {
21
25class NIM_SDK_CPPWRAPPER_DLL_API Talk {
26public:
28 typedef std::function<void(const SendMessageArc&)> SendMsgAckCallback;
30 typedef std::function<void(const IMMessage&)> ReceiveMsgCallback;
32 typedef std::function<void(const std::list<IMMessage>&)> ReceiveMsgsCallback;
34 typedef std::function<void(int64_t, int64_t)> FileUpPrgCallback;
36 typedef std::function<bool(const IMMessage&)> TeamNotificationFilter;
38 typedef std::function<void(const NIMResCode, const std::list<RecallMsgNotify>&)> RecallMsgsCallback;
40 typedef std::function<void(const BroadcastMessage&)> ReceiveBroadcastMsgCallback;
42 typedef std::function<void(const std::list<BroadcastMessage>&)> ReceiveBroadcastMsgsCallback;
44 typedef std::function<bool(const IMMessage&)> MessageFilter;
46 typedef std::function<std::string(const IMMessage&)> AntiCheatingFieldFillCallback;
47
64 static void RegSendMsgCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
65
73 static void SendMsg(const std::string& json_msg, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
74
82 static void SendMsg(const IMMessage& message, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
83
91 static bool StopSendMsg(const std::string& client_msg_id, const NIMMessageType& type, const std::string& json_extension = "");
92
102 static void RegReceiveCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
103
111 static void RegReceiveMessagesCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
112
130 static std::string CreateTextMessage(const std::string& receiver_id,
131 const NIMSessionType session_type,
132 const std::string& client_msg_id,
133 const std::string& content,
134 const MessageSetting& msg_setting,
135 int64_t timetag = 0,
136 int32_t sub_type = 0);
137
157 static std::string CreateImageMessage(const std::string& receiver_id,
158 const NIMSessionType session_type,
159 const std::string& client_msg_id,
160 const IMImage& image,
161 const std::string& file_path,
162 const MessageSetting& msg_setting,
163 int64_t timetag = 0,
164 int32_t sub_type = 0);
165
185 static std::string CreateFileMessage(const std::string& receiver_id,
186 const NIMSessionType session_type,
187 const std::string& client_msg_id,
188 const IMFile& file,
189 const std::string& file_path,
190 const MessageSetting& msg_setting,
191 int64_t timetag = 0,
192 int32_t sub_type = 0);
193
213 static std::string CreateAudioMessage(const std::string& receiver_id,
214 const NIMSessionType session_type,
215 const std::string& client_msg_id,
216 const IMAudio& audio,
217 const std::string& file_path,
218 const MessageSetting& msg_setting,
219 int64_t timetag = 0,
220 int32_t sub_type = 0);
221
241 static std::string CreateVideoMessage(const std::string& receiver_id,
242 const NIMSessionType session_type,
243 const std::string& client_msg_id,
244 const IMVideo& video,
245 const std::string& file_path,
246 const MessageSetting& msg_setting,
247 int64_t timetag = 0,
248 int32_t sub_type = 0);
249
267 static std::string CreateLocationMessage(const std::string& receiver_id,
268 const NIMSessionType session_type,
269 const std::string& client_msg_id,
270 const IMLocation& location,
271 const MessageSetting& msg_setting,
272 int64_t timetag = 0,
273 int32_t sub_type = 0);
274
292 static std::string CreateTipMessage(const std::string& receiver_id,
293 const NIMSessionType session_type,
294 const std::string& client_msg_id,
295 const std::string& tip,
296 const MessageSetting& msg_setting,
297 int64_t timetag = 0,
298 int32_t sub_type = 0);
299
319 static std::string CreateBotRobotMessage(const std::string& receiver_id,
320 const NIMSessionType session_type,
321 const std::string& client_msg_id,
322 const std::string& content,
323 const IMBotRobot& bot_msg,
324 const MessageSetting& msg_setting,
325 int64_t timetag = 0,
326 int32_t sub_type = 0);
327
345 static std::string CreateG2NetCallMessage(const std::string& receiver_id,
346 const NIMSessionType session_type,
347 const std::string& client_msg_id,
348 const std::string& msg_attach,
349 const MessageSetting& msg_setting,
350 int64_t timetag = 0,
351 int32_t sub_type = 0);
352
368 static std::string CreateRetweetMessage(const std::string& src_msg_json,
369 const std::string& client_msg_id,
370 const NIMSessionType retweet_to_session_type,
371 const std::string& retweet_to_session_id,
372 const MessageSetting& msg_setting,
373 int64_t timetag = 0);
374
381 static bool ParseIMMessage(const std::string& json_msg, IMMessage& msg);
382
389 static bool ParseImageMessageAttach(const IMMessage& msg, IMImage& image);
390
397 static bool ParseFileMessageAttach(const IMMessage& msg, IMFile& file);
398
405 static bool ParseAudioMessageAttach(const IMMessage& msg, IMAudio& audio);
406
413 static bool ParseVideoMessageAttach(const IMMessage& msg, IMVideo& video);
414
421 static bool ParseLocationMessageAttach(const IMMessage& msg, IMLocation& location);
422
429 static bool ParseBotRobotMessageAttach(const IMMessage& msg, IMBotRobot& robot_msg);
430
435 static void UnregTalkCb();
436
443 static void RegTeamNotificationFilter(const TeamNotificationFilter& filter, const std::string& json_extension = "");
444
451 static void RegMessageFilter(const MessageFilter& filter, const std::string& json_extension = "");
452
460 static void RegRecallMsgsCallback(const RecallMsgsCallback& cb, const std::string& json_extension = "");
461
478 static void RecallMsg(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, const std::string& json_extension = "");
479
500 static void RecallMsg2(const IMMessage& msg,
501 const std::string& notify,
502 const RecallMsgsCallback& cb,
503 const std::string& apnstext = "",
504 const std::string& pushpayloadconst = "",
505 const std::string& json_extension = "");
506
522 static void RecallMsgEx(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, nim_talk_recall_extra_params& extra_param);
523
529 static std::string GetAttachmentPathFromMsg(const IMMessage& msg);
530
540 static void RegReceiveBroadcastMsgCb(const ReceiveBroadcastMsgCallback& cb, const std::string& json_extension = "");
541
549 static void RegReceiveBroadcastMsgsCb(const ReceiveBroadcastMsgsCallback& cb, const std::string& json_extension = "");
550
558 static void ReplyMessage(const IMMessage& msg, const std::string& json_reply_msg, FileUpPrgCallback* prg_cb = nullptr);
559};
560
561} // namespace nim
562
563#endif //_NIM_SDK_CPP_TALK_H_
聊天功能;主要包括发送消息、接收消息等功能
Definition: nim_cpp_talk.h:25
std::function< void(const std::list< BroadcastMessage > &)> ReceiveBroadcastMsgsCallback
批量接收广播消息通知回调模板
Definition: nim_cpp_talk.h:42
std::function< void(const IMMessage &)> ReceiveMsgCallback
接收消息通知回调模板
Definition: nim_cpp_talk.h:30
std::function< bool(const IMMessage &)> MessageFilter
消息过滤器
Definition: nim_cpp_talk.h:44
std::function< void(int64_t, int64_t)> FileUpPrgCallback
发送多媒体消息文件上传过程回调模板
Definition: nim_cpp_talk.h:34
std::function< void(const SendMessageArc &)> SendMsgAckCallback
发送消息回执通知回调模板
Definition: nim_cpp_talk.h:28
std::function< std::string(const IMMessage &)> AntiCheatingFieldFillCallback
易盾反垃圾增强反作弊字段填充回调模板
Definition: nim_cpp_talk.h:46
std::function< void(const std::list< IMMessage > &)> ReceiveMsgsCallback
批量接收消息通知回调模板
Definition: nim_cpp_talk.h:32
std::function< void(const BroadcastMessage &)> ReceiveBroadcastMsgCallback
接收广播消息通知回调模板
Definition: nim_cpp_talk.h:40
std::function< void(const NIMResCode, const std::list< RecallMsgNotify > &)> RecallMsgsCallback
消息撤回通知回调模板
Definition: nim_cpp_talk.h:38
std::function< bool(const IMMessage &)> TeamNotificationFilter
群通知过滤器
Definition: nim_cpp_talk.h:36
namespace nim
NIMResCode
Definition: nim_chatroom_res_code_def.h:15
Message 通用辅助方法和数据结构定义
NIMMessageType
Definition: nim_msglog_def.h:269
定义导出宏
NIMSessionType
Definition: nim_session_def.h:16
Talk 辅助方法和数据结构定义
Definition: nim_talk_def.h:72
Definition: nim_talk_helper.h:638
语音消息附件
Definition: nim_talk_helper.h:555
波特机器人消息附件
Definition: nim_talk_helper.h:605
文件消息附件
Definition: nim_talk_helper.h:450
图片消息附件
Definition: nim_talk_helper.h:502
位置消息附件
Definition: nim_talk_helper.h:527
Definition: nim_talk_helper.h:281
小视频消息附件
Definition: nim_talk_helper.h:576
消息属性设置
Definition: nim_talk_helper.h:24
发送消息回执
Definition: nim_msg_helper.h:24