NIM SDK API  8.5.0
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>
15 #include "nim_cpp_wrapper/nim_sdk_cpp_wrapper.h"
20 namespace nim {
21 
25 class NIM_SDK_CPPWRAPPER_DLL_API Talk {
26 public:
27  typedef std::function<void(const SendMessageArc&)> SendMsgAckCallback;
28  typedef std::function<void(const IMMessage&)> ReceiveMsgCallback;
29  typedef std::function<void(const std::list<IMMessage>&)> ReceiveMsgsCallback;
30  typedef std::function<void(int64_t, int64_t)> FileUpPrgCallback;
31  typedef std::function<bool(const IMMessage&)> TeamNotificationFilter;
32  typedef std::function<void(const NIMResCode, const std::list<RecallMsgNotify>&)> RecallMsgsCallback;
33  typedef std::function<void(const BroadcastMessage&)> ReceiveBroadcastMsgCallback;
34  typedef std::function<void(const std::list<BroadcastMessage>&)> ReceiveBroadcastMsgsCallback;
35  typedef std::function<bool(const IMMessage&)> MessageFilter;
36  typedef std::function<std::string(const IMMessage&)> AntiCheatingFieldFillCallback;
54  static void RegSendMsgCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
55 
63  static void SendMsg(const std::string& json_msg, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
64 
72  static bool StopSendMsg(const std::string& client_msg_id, const NIMMessageType& type, const std::string& json_extension = "");
73 
83  static void RegReceiveCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
84 
92  static void RegReceiveMessagesCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
93 
111  static std::string CreateTextMessage(const std::string& receiver_id,
112  const NIMSessionType session_type,
113  const std::string& client_msg_id,
114  const std::string& content,
115  const MessageSetting& msg_setting,
116  int64_t timetag = 0,
117  int32_t sub_type = 0);
118 
138  static std::string CreateImageMessage(const std::string& receiver_id,
139  const NIMSessionType session_type,
140  const std::string& client_msg_id,
141  const IMImage& image,
142  const std::string& file_path,
143  const MessageSetting& msg_setting,
144  int64_t timetag = 0,
145  int32_t sub_type = 0);
146 
166  static std::string CreateFileMessage(const std::string& receiver_id,
167  const NIMSessionType session_type,
168  const std::string& client_msg_id,
169  const IMFile& file,
170  const std::string& file_path,
171  const MessageSetting& msg_setting,
172  int64_t timetag = 0,
173  int32_t sub_type = 0);
174 
194  static std::string CreateAudioMessage(const std::string& receiver_id,
195  const NIMSessionType session_type,
196  const std::string& client_msg_id,
197  const IMAudio& audio,
198  const std::string& file_path,
199  const MessageSetting& msg_setting,
200  int64_t timetag = 0,
201  int32_t sub_type = 0);
202 
222  static std::string CreateVideoMessage(const std::string& receiver_id,
223  const NIMSessionType session_type,
224  const std::string& client_msg_id,
225  const IMVideo& video,
226  const std::string& file_path,
227  const MessageSetting& msg_setting,
228  int64_t timetag = 0,
229  int32_t sub_type = 0);
230 
248  static std::string CreateLocationMessage(const std::string& receiver_id,
249  const NIMSessionType session_type,
250  const std::string& client_msg_id,
251  const IMLocation& location,
252  const MessageSetting& msg_setting,
253  int64_t timetag = 0,
254  int32_t sub_type = 0);
255 
273  static std::string CreateTipMessage(const std::string& receiver_id,
274  const NIMSessionType session_type,
275  const std::string& client_msg_id,
276  const std::string& tip_content,
277  const MessageSetting& msg_setting,
278  int64_t timetag = 0,
279  int32_t sub_type = 0);
280 
300  static std::string CreateBotRobotMessage(const std::string& receiver_id,
301  const NIMSessionType session_type,
302  const std::string& client_msg_id,
303  const std::string& content,
304  const IMBotRobot& bot_msg,
305  const MessageSetting& msg_setting,
306  int64_t timetag = 0,
307  int32_t sub_type = 0);
308 
326  static std::string CreateG2NetCallMessage(const std::string& receiver_id,
327  const NIMSessionType session_type,
328  const std::string& client_msg_id,
329  const std::string& msg_attach,
330  const MessageSetting& msg_setting,
331  int64_t timetag = 0,
332  int32_t sub_type = 0);
333 
349  static std::string CreateRetweetMessage(const std::string& src_msg_json,
350  const std::string& client_msg_id,
351  const NIMSessionType retweet_to_session_type,
352  const std::string& retweet_to_session_id,
353  const MessageSetting& msg_setting,
354  int64_t timetag = 0);
355 
362  static bool ParseIMMessage(const std::string& json_msg, IMMessage& msg);
363 
370  static bool ParseImageMessageAttach(const IMMessage& msg, IMImage& image);
371 
378  static bool ParseFileMessageAttach(const IMMessage& msg, IMFile& file);
379 
386  static bool ParseAudioMessageAttach(const IMMessage& msg, IMAudio& audio);
387 
394  static bool ParseVideoMessageAttach(const IMMessage& msg, IMVideo& video);
395 
402  static bool ParseLocationMessageAttach(const IMMessage& msg, IMLocation& location);
403 
410  static bool ParseBotRobotMessageAttach(const IMMessage& msg, IMBotRobot& robot_msg);
411 
416  static void UnregTalkCb();
417 
424  static void RegTeamNotificationFilter(const TeamNotificationFilter& filter, const std::string& json_extension = "");
425 
432  static void RegMessageFilter(const MessageFilter& filter, const std::string& json_extension = "");
433 
441  static void RegRecallMsgsCallback(const RecallMsgsCallback& cb, const std::string& json_extension = "");
442 
459  static void RecallMsg(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, const std::string& json_extension = "");
460 
481  static void RecallMsg2(const IMMessage& msg,
482  const std::string& notify,
483  const RecallMsgsCallback& cb,
484  const std::string& apnstext = "",
485  const std::string& pushpayloadconst = "",
486  const std::string& json_extension = "");
487 
503  static void RecallMsgEx(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, nim_talk_recall_extra_params& extra_param);
504 
510  static std::string GetAttachmentPathFromMsg(const IMMessage& msg);
511 
521  static void RegReceiveBroadcastMsgCb(const ReceiveBroadcastMsgCallback& cb, const std::string& json_extension = "");
522 
530  static void RegReceiveBroadcastMsgsCb(const ReceiveBroadcastMsgsCallback& cb, const std::string& json_extension = "");
531 
539  static void ReplyMessage(const IMMessage& msg, const std::string& json_reply_msg, FileUpPrgCallback* prg_cb = nullptr);
540 };
541 
542 } // namespace nim
543 
544 #endif //_NIM_SDK_CPP_TALK_H_
nim::BroadcastMessage
Definition: nim_talk_helper.h:545
nim::Talk::ReceiveMsgsCallback
std::function< void(const std::list< IMMessage > &)> ReceiveMsgsCallback
Definition: nim_cpp_talk.h:29
nim::Talk::FileUpPrgCallback
std::function< void(int64_t, int64_t)> FileUpPrgCallback
Definition: nim_cpp_talk.h:30
nim::IMBotRobot
波特机器人消息附件
Definition: nim_talk_helper.h:519
nim::Talk::MessageFilter
std::function< bool(const IMMessage &)> MessageFilter
Definition: nim_cpp_talk.h:35
nim::Talk
聊天功能;主要包括发送消息、接收消息等功能
Definition: nim_cpp_talk.h:25
nim_talk_helper.h
Talk 辅助方法和数据结构定义
nim::Talk::AntiCheatingFieldFillCallback
std::function< std::string(const IMMessage &)> AntiCheatingFieldFillCallback
Definition: nim_cpp_talk.h:36
nim::Talk::SendMsgAckCallback
std::function< void(const SendMessageArc &)> SendMsgAckCallback
Definition: nim_cpp_talk.h:27
nim
namespace nim
nim::Talk::ReceiveMsgCallback
std::function< void(const IMMessage &)> ReceiveMsgCallback
Definition: nim_cpp_talk.h:28
nim::IMLocation
位置消息附件
Definition: nim_talk_helper.h:448
nim::Talk::RecallMsgsCallback
std::function< void(const NIMResCode, const std::list< RecallMsgNotify > &)> RecallMsgsCallback
Definition: nim_cpp_talk.h:32
nim::SendMessageArc
发送消息回执
Definition: nim_msg_helper.h:22
nim::MessageSetting
消息属性设置
Definition: nim_talk_helper.h:24
nim::IMAudio
语音消息附件
Definition: nim_talk_helper.h:473
nim::Talk::ReceiveBroadcastMsgCallback
std::function< void(const BroadcastMessage &)> ReceiveBroadcastMsgCallback
Definition: nim_cpp_talk.h:33
nim::IMImage
图片消息附件
Definition: nim_talk_helper.h:425
nim::Talk::ReceiveBroadcastMsgsCallback
std::function< void(const std::list< BroadcastMessage > &)> ReceiveBroadcastMsgsCallback
Definition: nim_cpp_talk.h:34
nim::IMFile
文件消息附件
Definition: nim_talk_helper.h:378
nim_msg_helper.h
Message 通用辅助方法和数据结构定义
nim::IMVideo
小视频消息附件
Definition: nim_talk_helper.h:493
nim::IMMessage
Definition: nim_talk_helper.h:232
nim::Talk::TeamNotificationFilter
std::function< bool(const IMMessage &)> TeamNotificationFilter
Definition: nim_cpp_talk.h:31