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 using SendMsgAckCallback = std::function<void(const SendMessageArc&)>;
30 using ReceiveMsgCallback = std::function<void(const IMMessage&)>;
32 using ReceiveMsgsCallback = std::function<void(const std::list<IMMessage>&)>;
34 using FileUpPrgCallback = std::function<void(int64_t, int64_t)>;
36 using TeamNotificationFilter = std::function<bool(const IMMessage&)>;
38 using RecallMsgsCallback = std::function<void(const NIMResCode, const std::list<RecallMsgNotify>&)>;
40 using ReceiveBroadcastMsgCallback = std::function<void(const BroadcastMessage&)>;
42 using ReceiveBroadcastMsgsCallback = std::function<void(const std::list<BroadcastMessage>&)>;
44 using MessageFilter = std::function<bool(const IMMessage&)>;
46 using MessageChangedCallback = std::function<void(const std::list<IMMessage>&)>;
48 using StopStreamingMessageCallback = std::function<void(NIMResCode)>;
50 using RedoAIMessageCallback = std::function<void(NIMResCode)>;
51
79 static void RegSendMsgCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
80
110 static void SendMsg(const std::string& json_msg, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
111
143 static void SendMsg(const IMMessage& message, const std::string& json_extension = "", FileUpPrgCallback* pcb = nullptr);
144 static void SendMsg(const IMMessage& message, const std::string& json_extension = "", FileUpPrgCallback pcb = nullptr);
145
154 static void SendMessageWithOption(const IMMessage& message, const IMMessageSendOption& option, const FileUpPrgCallback& pcb = nullptr);
155
166 static bool StopSendMsg(const std::string& client_msg_id, const NIMMessageType& type, const std::string& json_extension = "");
167
185 static void RegReceiveCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
186
202 static void RegReceiveMessagesCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
203
213 static void RegMessageChangedCb(const MessageChangedCallback& cb, const std::string& json_extension = "");
214
237 static std::string CreateTextMessage(const std::string& receiver_id,
238 const NIMSessionType session_type,
239 const std::string& client_msg_id,
240 const std::string& content,
241 const MessageSetting& msg_setting,
242 int64_t timetag = 0,
243 int32_t sub_type = 0);
244
273 static std::string CreateImageMessage(const std::string& receiver_id,
274 const NIMSessionType session_type,
275 const std::string& client_msg_id,
276 const IMImage& image,
277 const std::string& file_path,
278 const MessageSetting& msg_setting,
279 int64_t timetag = 0,
280 int32_t sub_type = 0);
281
310 static std::string CreateFileMessage(const std::string& receiver_id,
311 const NIMSessionType session_type,
312 const std::string& client_msg_id,
313 const IMFile& file,
314 const std::string& file_path,
315 const MessageSetting& msg_setting,
316 int64_t timetag = 0,
317 int32_t sub_type = 0);
318
347 static std::string CreateAudioMessage(const std::string& receiver_id,
348 const NIMSessionType session_type,
349 const std::string& client_msg_id,
350 const IMAudio& audio,
351 const std::string& file_path,
352 const MessageSetting& msg_setting,
353 int64_t timetag = 0,
354 int32_t sub_type = 0);
355
384 static std::string CreateVideoMessage(const std::string& receiver_id,
385 const NIMSessionType session_type,
386 const std::string& client_msg_id,
387 const IMVideo& video,
388 const std::string& file_path,
389 const MessageSetting& msg_setting,
390 int64_t timetag = 0,
391 int32_t sub_type = 0);
392
419 static std::string CreateLocationMessage(const std::string& receiver_id,
420 const NIMSessionType session_type,
421 const std::string& client_msg_id,
422 const IMLocation& location,
423 const MessageSetting& msg_setting,
424 int64_t timetag = 0,
425 int32_t sub_type = 0);
426
449 static std::string CreateTipMessage(const std::string& receiver_id,
450 const NIMSessionType session_type,
451 const std::string& client_msg_id,
452 const std::string& tip,
453 const MessageSetting& msg_setting,
454 int64_t timetag = 0,
455 int32_t sub_type = 0);
456
478 static std::string CreateBotRobotMessage(const std::string& receiver_id,
479 const NIMSessionType session_type,
480 const std::string& client_msg_id,
481 const std::string& content,
482 const IMBotRobot& bot_msg,
483 const MessageSetting& msg_setting,
484 int64_t timetag = 0,
485 int32_t sub_type = 0);
486
512 static std::string CreateG2NetCallMessage(const std::string& receiver_id,
513 const NIMSessionType session_type,
514 const std::string& client_msg_id,
515 const std::string& msg_attach,
516 const MessageSetting& msg_setting,
517 int64_t timetag = 0,
518 int32_t sub_type = 0);
519
541 static std::string CreateRetweetMessage(const std::string& src_msg_json,
542 const std::string& client_msg_id,
543 const NIMSessionType retweet_to_session_type,
544 const std::string& retweet_to_session_id,
545 const MessageSetting& msg_setting,
546 int64_t timetag = 0);
547
554 static bool ParseIMMessage(const std::string& json_msg, IMMessage& msg);
555
562 static bool ParseImageMessageAttach(const IMMessage& msg, IMImage& image);
563
570 static bool ParseFileMessageAttach(const IMMessage& msg, IMFile& file);
571
578 static bool ParseAudioMessageAttach(const IMMessage& msg, IMAudio& audio);
579
586 static bool ParseVideoMessageAttach(const IMMessage& msg, IMVideo& video);
587
594 static bool ParseLocationMessageAttach(const IMMessage& msg, IMLocation& location);
595
604 static bool ParseBotRobotMessageAttach(const IMMessage& msg, IMBotRobot& robot_msg);
605
610 static void UnregTalkCb();
611
625 static void RegTeamNotificationFilter(const TeamNotificationFilter& filter, const std::string& json_extension = "");
626
639 static void RegMessageFilter(const MessageFilter& filter, const std::string& json_extension = "");
640
654 static void RegRecallMsgsCallback(const RecallMsgsCallback& cb, const std::string& json_extension = "");
655
696 static void RecallMsg(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, const std::string& json_extension = "");
697
742 static void RecallMsg2(const IMMessage& msg,
743 const std::string& notify,
744 const RecallMsgsCallback& cb,
745 const std::string& apnstext = "",
746 const std::string& pushpayloadconst = "",
747 const std::string& json_extension = "");
748
802 static void RecallMsgEx(const IMMessage& msg, const std::string& notify, const RecallMsgsCallback& cb, nim_talk_recall_extra_params& extra_param);
803
814 static std::string GetAttachmentPathFromMsg(const IMMessage& msg);
815
834 static void RegReceiveBroadcastMsgCb(const ReceiveBroadcastMsgCallback& cb, const std::string& json_extension = "");
835
851 static void RegReceiveBroadcastMsgsCb(const ReceiveBroadcastMsgsCallback& cb, const std::string& json_extension = "");
852
877 static void ReplyMessage(const IMMessage& msg, const std::string& json_reply_msg, FileUpPrgCallback* prg_cb = nullptr);
878 static void ReplyMessage(const IMMessage& former_msg, const IMMessage& reply_msg, FileUpPrgCallback* prg_cb = nullptr);
879
887 static void ReplyMessageWithOption(const IMMessage& former_msg,
888 const IMMessage& reply_msg,
889 const ReplyMessageOption& option,
890 FileUpPrgCallback* prg_cb = nullptr);
891
900 static void StopStreamingMessage(const IMMessage& message, const StopStreamingMessageParam& parameter, const StopStreamingMessageCallback& cb);
901
910 static void RedoAIMessage(const IMMessage& message, const RedoAIMessageParam& parameter, const RedoAIMessageCallback& cb);
911};
912
913} // namespace nim
914
915#endif //_NIM_SDK_CPP_TALK_H_
聊天功能,主要包括消息收发、消息撤回、消息回复(Thread 场景)等功能
Definition: nim_cpp_talk.h:25
std::function< bool(const IMMessage &)> MessageFilter
消息过滤器
Definition: nim_cpp_talk.h:44
std::function< void(NIMResCode)> RedoAIMessageCallback
重新输出数字人消息回调
Definition: nim_cpp_talk.h:50
std::function< void(const SendMessageArc &)> SendMsgAckCallback
发送消息回执通知回调
Definition: nim_cpp_talk.h:28
std::function< void(const std::list< IMMessage > &)> MessageChangedCallback
消息被更新通知回调
Definition: nim_cpp_talk.h:46
std::function< void(int64_t, int64_t)> FileUpPrgCallback
发送多媒体消息文件上传过程回调
Definition: nim_cpp_talk.h:34
std::function< void(const BroadcastMessage &)> ReceiveBroadcastMsgCallback
接收广播消息通知回调
Definition: nim_cpp_talk.h:40
std::function< void(NIMResCode)> StopStreamingMessageCallback
停止流式消息回调
Definition: nim_cpp_talk.h:48
std::function< void(const std::list< IMMessage > &)> ReceiveMsgsCallback
批量接收消息通知回调
Definition: nim_cpp_talk.h:32
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
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
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:27
Definition: nim_talk_def.h:96
Definition: nim_talk_helper.h:854
语音消息附件
Definition: nim_talk_helper.h:756
波特机器人消息附件
Definition: nim_talk_helper.h:812
文件消息附件
Definition: nim_talk_helper.h:640
图片消息附件
Definition: nim_talk_helper.h:697
位置消息附件
Definition: nim_talk_helper.h:724
Definition: nim_talk_helper.h:440
Definition: nim_talk_helper.h:424
小视频消息附件
Definition: nim_talk_helper.h:779
消息属性设置
Definition: nim_talk_helper.h:25
Definition: nim_talk_helper.h:882
发送消息回执
Definition: nim_msg_helper.h:24
Definition: nim_talk_helper.h:864