NIM SDK API
9.0.0
|
聊天功能;主要包括发送消息、接收消息等功能 More...
#include <nim_cpp_talk.h>
Public Types | |
typedef std::function< void(const SendMessageArc &)> | SendMsgAckCallback |
typedef std::function< void(const IMMessage &)> | ReceiveMsgCallback |
typedef std::function< void(const std::list< IMMessage > &)> | ReceiveMsgsCallback |
typedef std::function< void(int64_t, int64_t)> | FileUpPrgCallback |
typedef std::function< bool(const IMMessage &)> | TeamNotificationFilter |
typedef std::function< void(const NIMResCode, const std::list< RecallMsgNotify > &)> | RecallMsgsCallback |
typedef std::function< void(const BroadcastMessage &)> | ReceiveBroadcastMsgCallback |
typedef std::function< void(const std::list< BroadcastMessage > &)> | ReceiveBroadcastMsgsCallback |
typedef std::function< bool(const IMMessage &)> | MessageFilter |
typedef std::function< std::string(const IMMessage &)> | AntiCheatingFieldFillCallback |
Static Public Member Functions | |
static void | RegSendMsgCb (const SendMsgAckCallback &cb, const std::string &json_extension="") |
static void | SendMsg (const std::string &json_msg, const std::string &json_extension="", FileUpPrgCallback *pcb=nullptr) |
static bool | StopSendMsg (const std::string &client_msg_id, const NIMMessageType &type, const std::string &json_extension="") |
static void | RegReceiveCb (const ReceiveMsgCallback &cb, const std::string &json_extension="") |
static void | RegReceiveMessagesCb (const ReceiveMsgsCallback &cb, const std::string &json_extension="") |
static std::string | CreateTextMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const std::string &content, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateImageMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const IMImage &image, const std::string &file_path, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateFileMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const IMFile &file, const std::string &file_path, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateAudioMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const IMAudio &audio, const std::string &file_path, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateVideoMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const IMVideo &video, const std::string &file_path, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateLocationMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const IMLocation &location, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateTipMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const std::string &tip, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateBotRobotMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const std::string &content, const IMBotRobot &bot_msg, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateG2NetCallMessage (const std::string &receiver_id, const NIMSessionType session_type, const std::string &client_msg_id, const std::string &msg_attach, const MessageSetting &msg_setting, int64_t timetag=0, int32_t sub_type=0) |
static std::string | CreateRetweetMessage (const std::string &src_msg_json, const std::string &client_msg_id, const NIMSessionType retweet_to_session_type, const std::string &retweet_to_session_id, const MessageSetting &msg_setting, int64_t timetag=0) |
static bool | ParseIMMessage (const std::string &json_msg, IMMessage &msg) |
static bool | ParseImageMessageAttach (const IMMessage &msg, IMImage &image) |
static bool | ParseFileMessageAttach (const IMMessage &msg, IMFile &file) |
static bool | ParseAudioMessageAttach (const IMMessage &msg, IMAudio &audio) |
static bool | ParseVideoMessageAttach (const IMMessage &msg, IMVideo &video) |
static bool | ParseLocationMessageAttach (const IMMessage &msg, IMLocation &location) |
static bool | ParseBotRobotMessageAttach (const IMMessage &msg, IMBotRobot &robot_msg) |
static void | UnregTalkCb () |
static void | RegTeamNotificationFilter (const TeamNotificationFilter &filter, const std::string &json_extension="") |
static void | RegMessageFilter (const MessageFilter &filter, const std::string &json_extension="") |
static void | RegRecallMsgsCallback (const RecallMsgsCallback &cb, const std::string &json_extension="") |
static void | RecallMsg (const IMMessage &msg, const std::string ¬ify, const RecallMsgsCallback &cb, const std::string &json_extension="") |
static void | RecallMsg2 (const IMMessage &msg, const std::string ¬ify, const RecallMsgsCallback &cb, const std::string &apnstext="", const std::string &pushpayloadconst="", const std::string &json_extension="") |
static void | RecallMsgEx (const IMMessage &msg, const std::string ¬ify, const RecallMsgsCallback &cb, nim_talk_recall_extra_params &extra_param) |
static std::string | GetAttachmentPathFromMsg (const IMMessage &msg) |
static void | RegReceiveBroadcastMsgCb (const ReceiveBroadcastMsgCallback &cb, const std::string &json_extension="") |
static void | RegReceiveBroadcastMsgsCb (const ReceiveBroadcastMsgsCallback &cb, const std::string &json_extension="") |
static void | ReplyMessage (const IMMessage &msg, const std::string &json_reply_msg, FileUpPrgCallback *prg_cb=nullptr) |
聊天功能;主要包括发送消息、接收消息等功能
typedef std::function<std::string(const IMMessage&)> nim::Talk::AntiCheatingFieldFillCallback |
易盾反垃圾增强反作弊字段填充回调模板
typedef std::function<void(int64_t, int64_t)> nim::Talk::FileUpPrgCallback |
发送多媒体消息文件上传过程回调模板
typedef std::function<bool(const IMMessage&)> nim::Talk::MessageFilter |
消息过滤器
typedef std::function<void(const NIMResCode, const std::list<RecallMsgNotify>&)> nim::Talk::RecallMsgsCallback |
消息撤回通知回调模板
typedef std::function<void(const BroadcastMessage&)> nim::Talk::ReceiveBroadcastMsgCallback |
接收广播消息通知回调模板
typedef std::function<void(const std::list<BroadcastMessage>&)> nim::Talk::ReceiveBroadcastMsgsCallback |
批量接收广播消息通知回调模板
typedef std::function<void(const IMMessage&)> nim::Talk::ReceiveMsgCallback |
接收消息通知回调模板
typedef std::function<void(const std::list<IMMessage>&)> nim::Talk::ReceiveMsgsCallback |
批量接收消息通知回调模板
typedef std::function<void(const SendMessageArc&)> nim::Talk::SendMsgAckCallback |
发送消息回执通知回调模板
typedef std::function<bool(const IMMessage&)> nim::Talk::TeamNotificationFilter |
群通知过滤器
|
static |
生成语音消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | audio | IMAudio,语音文件信息 |
[in] | file_path | 文件本地绝对路径 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成Tip消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | content | 内容 |
[in] | bot_msg | 机器人消息信息 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成文件消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | file | IMFile,文件信息 |
[in] | file_path | 文件本地绝对路径 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成Tip消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | msg_attach | ,G2话单json体包含type,channel,status,以及durations数组 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成图片消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | image | IMImage,图片文件信息 |
[in] | file_path | 文件本地绝对路径 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成位置消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | location | IMLocation,位置信息 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
由其他消息生成转发消息
[in] | src_msg_json | 原消息json |
[in] | client_msg_id | 新的客户端消息id,建议uuid |
[in] | retweet_to_session_type | 转发目标会话类型 NIMSessionType |
[in] | retweet_to_session_id | 转发目标ID |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
|
static |
生成文字消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | content | 文本内容 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成 Tips 消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | tip | Tip文本内容 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
生成视频消息内容,生成的字符串在调用SendMsg时直接传入
[in] | receiver_id | 聊天对象的 ID,如果是单聊,为用户帐号,如果是群聊,为群组 ID |
[in] | session_type | NIMSessionType,聊天类型,单聊或群组 |
[in] | client_msg_id | 客户端消息id,建议uuid |
[in] | video | IMVideo,视频文件信息 |
[in] | file_path | 文件本地绝对路径 |
[in] | msg_setting | 消息属性设置 |
[in] | timetag | 消息时间 |
[in] | sub_type | 消息子类型( > 0 ),由开发者自定义,服务端只负责透传 v7.8 |
|
static |
从消息体中获取附件(图片、语音、视频等)的本地路径
[in] | msg | 消息 |
通过得到的消息获得语音信息
[in] | msg | 消息 |
[out] | audio | 语音信息 |
|
static |
通过得到的消息获得机器人消息
[in] | msg | 消息 |
[out] | robot_msg | 机器人消息 |
通过得到的消息获得文件信息
[in] | msg | 消息 |
[out] | file | 文件信息 |
通过得到的消息获得图片信息
[in] | msg | 消息 |
[out] | image | 图片信息 |
|
static |
解析消息Json字符串
[in] | json_msg | 消息内容Json字符串 |
[out] | msg | 消息内容 |
|
static |
通过得到的消息获得位置信息
[in] | msg | 消息 |
[out] | location | 位置信息 |
通过得到的消息获得视频信息
[in] | msg | 消息 |
[out] | video | 视频信息 |
|
static |
撤回消息
[in] | msg | 消息 |
[in] | notify | 自定义通知消息 |
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 回调 |
|
static |
撤回消息
[in] | msg | 消息 |
[in] | notify | 自定义通知消息 |
[in] | cb | 回调 |
[in] | apnstext | 透传消息推送文本,不填则不推送 |
[in] | pushpayloadconst | 第三方自定义的推送属性,限制json,长度2048 |
[in] | json_extension | json扩展参数(备用,目前不需要) |
|
static |
撤回消息
[in] | msg | 消息 |
[in] | notify | 自定义通知消息 |
[in] | cb | 回调 |
[in] | extra_param | 额外的参数,包含apnstext、pushpayload、json_extension、env_config、user_data |
|
static |
(全局回调)注册消息过滤接口 (堵塞线程,谨慎使用,避免耗时行为)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | filter | 过滤接口 |
|
static |
(全局回调)注册消息回调通知接口
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 回调 |
|
static |
(全局回调)注册接收广播消息回调 (全局注册)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 接收消息的回调函数 |
|
static |
(全局回调)注册批量接收广播消息回调 (全局注册)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 接收消息的回调函数 |
|
static |
(全局回调)注册接收消息回调 (建议全局注册,统一接受回调后分发消息到具体的会话)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 接收消息的回调函数 |
|
static |
(全局回调)注册批量接收消息回调 (建议全局注册,统一接受回调后分发消息到具体的会话)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 接收消息的回调函数 |
|
static |
(全局回调)注册发送消息回调函数 (必须全局注册,统一接受回调后分发消息到具体的会话。注意:客户端发包之后,服务器不一定会返回!!!)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | cb | 发送消息的回调函数 |
|
static |
(全局回调)注册群通知过滤接口 (堵塞线程,谨慎使用,避免耗时行为)
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | filter | 过滤接口 |
|
static |
回复消息thread 聊天场景
[in] | msg | 被回复消息的消息体 |
[in] | json_reply_msg | 回复消息的消息体,可通过各种createxxxmessage接口创建 |
[in] | prg_cb | 传进度的回调函数, 如果发送的消息里包含了文件资源,则通过此回调函数通知上传进度 |
|
static |
发送消息
[in] | json_msg | 消息体Json字符串,可以通过CreateXXXMessage方法自动创建 |
[in] | json_extension | json扩展参数(备用,目前不需要) |
[in] | pcb | 上传进度的回调函数, 如果发送的消息里包含了文件资源,则通过此回调函数通知上传进度 |
|
static |
停止正在发送中的消息(目前只支持发送文件消息时的终止)
[in] | client_msg_id | 停止发送的消息客户端id |
[in] | type | 停止发送的消息类型 |
[in] | json_extension | json扩展参数(备用,目前不需要) |
|
static |
反注册Talk提供的所有回调