NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
nim_cpp_talk.h
浏览该文件的文档.
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
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;
45
73 static void RegSendMsgCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
74
104 static void SendMsg(const std::string& json_msg, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
105
137 static void SendMsg(const IMMessage& message, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
138 static void SendMsg(const IMMessage& message, const std::string& json_extension = "", FileUpPrgCallback pcb = nullptr);
139
148 static void SendMessageWithOption(const IMMessage& message, const IMMessageSendOption& option, const FileUpPrgCallback& pcb = nullptr);
149
160 static bool StopSendMsg(const std::string& client_msg_id, const NIMMessageType& type, const std::string& json_extension = "");
161
179 static void RegReceiveCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
180
196 static void RegReceiveMessagesCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
197
220 static std::string CreateTextMessage(const std::string& receiver_id,
221 const NIMSessionType session_type,
222 const std::string& client_msg_id,
223 const std::string& content,
224 const MessageSetting& msg_setting,
225 int64_t timetag = 0,
226 int32_t sub_type = 0);
227
256 static std::string CreateImageMessage(const std::string& receiver_id,
257 const NIMSessionType session_type,
258 const std::string& client_msg_id,
259 const IMImage& image,
260 const std::string& file_path,
261 const MessageSetting& msg_setting,
262 int64_t timetag = 0,
263 int32_t sub_type = 0);
264
293 static std::string CreateFileMessage(const std::string& receiver_id,
294 const NIMSessionType session_type,
295 const std::string& client_msg_id,
296 const IMFile& file,
297 const std::string& file_path,
298 const MessageSetting& msg_setting,
299 int64_t timetag = 0,
300 int32_t sub_type = 0);
301
330 static std::string CreateAudioMessage(const std::string& receiver_id,
331 const NIMSessionType session_type,
332 const std::string& client_msg_id,
333 const IMAudio& audio,
334 const std::string& file_path,
335 const MessageSetting& msg_setting,
336 int64_t timetag = 0,
337 int32_t sub_type = 0);
338
367 static std::string CreateVideoMessage(const std::string& receiver_id,
368 const NIMSessionType session_type,
369 const std::string& client_msg_id,
370 const IMVideo& video,
371 const std::string& file_path,
372 const MessageSetting& msg_setting,
373 int64_t timetag = 0,
374 int32_t sub_type = 0);
375
402 static std::string CreateLocationMessage(const std::string& receiver_id,
403 const NIMSessionType session_type,
404 const std::string& client_msg_id,
405 const IMLocation& location,
406 const MessageSetting& msg_setting,
407 int64_t timetag = 0,
408 int32_t sub_type = 0);
409
432 static std::string CreateTipMessage(const std::string& receiver_id,
433 const NIMSessionType session_type,
434 const std::string& client_msg_id,
435 const std::string& tip,
436 const MessageSetting& msg_setting,
437 int64_t timetag = 0,
438 int32_t sub_type = 0);
439
461 static std::string CreateBotRobotMessage(const std::string& receiver_id,
462 const NIMSessionType session_type,
463 const std::string& client_msg_id,
464 const std::string& content,
465 const IMBotRobot& bot_msg,
466 const MessageSetting& msg_setting,
467 int64_t timetag = 0,
468 int32_t sub_type = 0);
469
495 static std::string CreateG2NetCallMessage(const std::string& receiver_id,
496 const NIMSessionType session_type,
497 const std::string& client_msg_id,
498 const std::string& msg_attach,
499 const MessageSetting& msg_setting,
500 int64_t timetag = 0,
501 int32_t sub_type = 0);
502
524 static std::string CreateRetweetMessage(const std::string& src_msg_json,
525 const std::string& client_msg_id,
526 const NIMSessionType retweet_to_session_type,
527 const std::string& retweet_to_session_id,
528 const MessageSetting& msg_setting,
529 int64_t timetag = 0);
530
537 static bool ParseIMMessage(const std::string& json_msg, IMMessage& msg);
538
545 static bool ParseImageMessageAttach(const IMMessage& msg, IMImage& image);
546
553 static bool ParseFileMessageAttach(const IMMessage& msg, IMFile& file);
554
561 static bool ParseAudioMessageAttach(const IMMessage& msg, IMAudio& audio);
562
569 static bool ParseVideoMessageAttach(const IMMessage& msg, IMVideo& video);
570
577 static bool ParseLocationMessageAttach(const IMMessage& msg, IMLocation& location);
578
587 static bool ParseBotRobotMessageAttach(const IMMessage& msg, IMBotRobot& robot_msg);
588
593 static void UnregTalkCb();
594
608 static void RegTeamNotificationFilter(const TeamNotificationFilter& filter, const std::string& json_extension = "");
609
622 static void RegMessageFilter(const MessageFilter& filter, const std::string& json_extension = "");
623
637 static void RegRecallMsgsCallback(const RecallMsgsCallback& cb, const std::string& json_extension = "");
638
679 static void RecallMsg(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, const std::string& json_extension = "");
680
725 static void RecallMsg2(const IMMessage& msg,
726 const std::string& notify,
727 const RecallMsgsCallback& cb,
728 const std::string& apnstext = "",
729 const std::string& pushpayloadconst = "",
730 const std::string& json_extension = "");
731
785 static void RecallMsgEx(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, nim_talk_recall_extra_params& extra_param);
786
797 static std::string GetAttachmentPathFromMsg(const IMMessage& msg);
798
817 static void RegReceiveBroadcastMsgCb(const ReceiveBroadcastMsgCallback& cb, const std::string& json_extension = "");
818
834 static void RegReceiveBroadcastMsgsCb(const ReceiveBroadcastMsgsCallback& cb, const std::string& json_extension = "");
835
860 static void ReplyMessage(const IMMessage& msg, const std::string& json_reply_msg, FileUpPrgCallback* prg_cb = nullptr);
861 static void ReplyMessage(const IMMessage& former_msg, const IMMessage& reply_msg, FileUpPrgCallback* prg_cb = nullptr);
862
870 static void ReplyMessageWithOption(const IMMessage& former_msg,
871 const IMMessage& reply_msg,
872 const ReplyMessageOption& option,
873 FileUpPrgCallback* prg_cb = nullptr);
874};
875
876} // namespace nim
877
878#endif //_NIM_SDK_CPP_TALK_H_
聊天功能,主要包括消息收发、消息撤回、消息回复(Thread 场景)等功能
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< 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
Message 通用辅助方法和数据结构定义
NIMMessageType
Definition: nim_msglog_def.h:309
定义导出宏
#define NIM_SDK_CPPWRAPPER_DLL_API
Definition: nim_sdk_cpp_wrapper.h:38
NIMSessionType
Definition: nim_session_def.h:16
Talk 辅助方法和数据结构定义
NIMResCode
Definition: public_defines.h:21
unsigned char bool
Definition: stdbool.h:25
Definition: nim_talk_def.h:72
Definition: nim_talk_helper.h:745
语音消息附件
Definition: nim_talk_helper.h:647
波特机器人消息附件
Definition: nim_talk_helper.h:703
文件消息附件
Definition: nim_talk_helper.h:531
图片消息附件
Definition: nim_talk_helper.h:588
位置消息附件
Definition: nim_talk_helper.h:615
Definition: nim_talk_helper.h:339
Definition: nim_talk_helper.h:323
小视频消息附件
Definition: nim_talk_helper.h:670
消息属性设置
Definition: nim_talk_helper.h:25
发送消息回执
Definition: nim_msg_helper.h:24