floo::BMXChatServiceListener
聊天监听者
#include <bmx_chat_service_listener.h>
Public Functions
Name | |
---|---|
BMXChatServiceListener() 构造函数 |
|
virtual | ~BMXChatServiceListener() 析构函数 |
virtual void | onStatusChanged(BMXMessagePtr msg, BMXErrorCode error) 消息发送状态发生变化 |
virtual void | onAttachmentUploadProgressChanged(BMXMessagePtr msg, int percent) 附件上传进度发送变化 |
virtual void | onRecallStatusChanged(BMXMessagePtr msg, BMXErrorCode error) 消息撤回状态发送变化 |
virtual void | onReceive(const BMXMessageList & list) 收到消息 |
virtual void | onReceiveCommandMessages(const BMXMessageList & list) 收到命令消息 |
virtual void | onReceiveSystemMessages(const BMXMessageList & list) 收到系统通知消息 |
virtual void | onReceiveReadAcks(const BMXMessageList & list) 收到消息已读回执 |
virtual void | onReceiveDeliverAcks(const BMXMessageList & list) 收到消息已送达回执 |
virtual void | onReceiveRecallMessages(const BMXMessageList & list) 收到撤回消息 |
virtual void | onReceiveReadCancels(const BMXMessageList & list) 收到消息已读取消(多设备其他设备同步消息已读状态变为未读) |
virtual void | onReceiveReadAllMessages(const BMXMessageList & list) 收到消息全部已读(多设备同步某消息之前消息全部设置为已读) |
virtual void | onReceiveDeleteMessages(const BMXMessageList & list) 收到删除消息 (多设备同步删除消息) |
virtual void | onReceivePlayAcks(const BMXMessageList & list) 收到音频/视频消息已播放回执 |
virtual void | onAttachmentStatusChanged(BMXMessagePtr msg, BMXErrorCode error, int percent) 附件下载状态发生变化 |
virtual void | onAttachmentDownloadByUrlStatusChanged(int64_t msgId, BMXErrorCode error, int percent) 附件下载状态发生变化 |
virtual void | onRetrieveHistoryMessages(BMXConversationPtr conversation) 拉取历史消息 |
virtual void | onLoadAllConversation() 已经加载完未读会话列表 |
virtual void | onConversationCreate(BMXConversationPtr conversation, BMXMessagePtr msg) 本地创建新会话 |
virtual void | onConversationDelete(int64_t conversationId, BMXErrorCode error) 删除会话 |
virtual void | onTotalUnreadCountChanged(int unreadCount) 更新总未读数 |
void | registerChatService(BMXChatService * service) 注册BMXChatServiceListener绑定到的BMXChatService(SDK内部自动注册) |
Protected Attributes
Name | |
---|---|
BMXChatService * | mService |
Public Functions Documentation
function BMXChatServiceListener
inline BMXChatServiceListener()
构造函数
Example:
function ~BMXChatServiceListener
inline virtual ~BMXChatServiceListener()
析构函数
Example:
function onStatusChanged
inline virtual void onStatusChanged(
BMXMessagePtr msg,
BMXErrorCode error
)
消息发送状态发生变化
Parameters:
- msg 发生状态变化的消息
- error 状态错误码
Example:
void ChatListener::onStatusChanged(BMXMessagePtr msg, BMXErrorCode error) {
mvwaddstr(notifyWindow, 1, 1, "ChatListener onStatusChanged message");
mvwaddstr(notifyWindow, 2, 1, std::to_string(msg->msgId()).c_str());
char* status = "unkonw status";
switch (msg->deliveryStatus()) {
case BMXMessage::DeliveryStatus::New:
status = "New";
break;
case BMXMessage::DeliveryStatus::Delivering:
status = "Delivering";
break;
case BMXMessage::DeliveryStatus::Deliveried:
status = "Deliveried";
showConversation(); //发送成功展示消息 (仅展示maximtest1 和 maximtest2的对话)
break;
case BMXMessage::DeliveryStatus::Failed:
status = "Failed";
break;
case BMXMessage::DeliveryStatus::Recalled:
status = "Recalled";
function onAttachmentUploadProgressChanged
inline virtual void onAttachmentUploadProgressChanged(
BMXMessagePtr msg,
int percent
)
附件上传进度发送变化
Parameters:
- msg 上传附件的消息
- percent 附件上传的进度
Example:
function onRecallStatusChanged
inline virtual void onRecallStatusChanged(
BMXMessagePtr msg,
BMXErrorCode error
)
消息撤回状态发送变化
Parameters:
- msg 撤回状态发生变化的消息
- error 状态错误码
Example:
function onReceive
inline virtual void onReceive(
const BMXMessageList & list
)
收到消息
Parameters:
- list 接收到的消息列表
Example:
void ChatListener::onReceive(const BMXMessageList& list) {
for (auto msg : list) {
draw_notify(notifyWindow);
mvwaddstr(notifyWindow, 1, 1, "ChatListener onReceive message");
mvwaddstr(notifyWindow, 2, 1, msg->senderName().c_str());
if (msg->extension().size()) {
if (msg->extension().find("typing") != std::string::npos) {
mvwaddstr(notifyWindow, 3, 1, "sender is typing");
} else {
mvwaddstr(notifyWindow, 3, 1, "sender is endtyping");
}
} else {
mvwaddstr(notifyWindow, 3, 1, msg->content().c_str());
}
}
showConversation(); //接收消息展示消息 (仅展示maximtest1 和 maximtest2的对话)
touchwin(stdscr);
refresh();
function onReceiveCommandMessages
inline virtual void onReceiveCommandMessages(
const BMXMessageList & list
)
收到命令消息
Parameters:
- list 接收到的消息列表
Example:
function onReceiveSystemMessages
inline virtual void onReceiveSystemMessages(
const BMXMessageList & list
)
收到系统通知消息
Parameters:
- list 接收到的系统消息列表
Example:
function onReceiveReadAcks
inline virtual void onReceiveReadAcks(
const BMXMessageList & list
)
收到消息已读回执
Parameters:
- list 接收到的已读回执消息列表
Example:
void ChatListener::onReceiveReadAcks(const BMXMessageList& list) {
for (auto msg : list) {
draw_notify(notifyWindow);
mvwaddstr(notifyWindow, 1, 1, "ChatListener onReceiveReadAcks message");
mvwaddstr(notifyWindow, 2, 1, std::to_string(msg->msgId()).c_str());
mvwaddstr(notifyWindow, 3, 1, msg->content().c_str());
}
touchwin(stdscr);
refresh();
function onReceiveDeliverAcks
inline virtual void onReceiveDeliverAcks(
const BMXMessageList & list
)
收到消息已送达回执
Parameters:
- list 接收到的已送达回执消息列表
Example:
function onReceiveRecallMessages
inline virtual void onReceiveRecallMessages(
const BMXMessageList & list
)
收到撤回消息
Parameters:
- list 接收到的撤回消息列表
Example:
function onReceiveReadCancels
inline virtual void onReceiveReadCancels(
const BMXMessageList & list
)
收到消息已读取消(多设备其他设备同步消息已读状态变为未读)
Parameters:
- list 接收到的消息已读取消消息列表
Example:
function onReceiveReadAllMessages
inline virtual void onReceiveReadAllMessages(
const BMXMessageList & list
)
收到消息全部已读(多设备同步某消息之前消息全部设置为已读)
Parameters:
- list 接收到的消息全部已读消息列表
Example:
function onReceiveDeleteMessages
inline virtual void onReceiveDeleteMessages(
const BMXMessageList & list
)
收到删除消息 (多设备同步删除消息)
Parameters:
- list 接收到的删除消息列表
Example:
function onReceivePlayAcks
inline virtual void onReceivePlayAcks(
const BMXMessageList & list
)
收到音频/视频消息已播放回执
Parameters:
- list 接收到的音频/视频消息已播放回执消息列表
Example:
function onAttachmentStatusChanged
inline virtual void onAttachmentStatusChanged(
BMXMessagePtr msg,
BMXErrorCode error,
int percent
)
附件下载状态发生变化
Parameters:
- msg 发生下载状态变化的消息
- error 状态错误码
- percent 附件下载的进度
Example:
function onAttachmentDownloadByUrlStatusChanged
inline virtual void onAttachmentDownloadByUrlStatusChanged(
int64_t msgId,
BMXErrorCode error,
int percent
)
附件下载状态发生变化
Parameters:
- msgId 发生下载状态变化的消息Id
- error 状态错误码
- percent 附件下载的进度
Example:
function onRetrieveHistoryMessages
inline virtual void onRetrieveHistoryMessages(
BMXConversationPtr conversation
)
拉取历史消息
Parameters:
- conversation 发生了拉取指历史消息的会话
Example:
function onLoadAllConversation
inline virtual void onLoadAllConversation()
已经加载完未读会话列表
Example:
function onConversationCreate
inline virtual void onConversationCreate(
BMXConversationPtr conversation,
BMXMessagePtr msg
)
本地创建新会话
Parameters:
- conversation 新创建的本地会话
- msg 会话的最新消息,存在返回不存在返回为空
Example:
function onConversationDelete
inline virtual void onConversationDelete(
int64_t conversationId,
BMXErrorCode error
)
删除会话
Parameters:
- conversationId 删除的本地会话id
- error 状态错误码
Example:
function onTotalUnreadCountChanged
inline virtual void onTotalUnreadCountChanged(
int unreadCount
)
更新总未读数
Parameters:
- unreadCount 本地全部会话未读总数
Example:
function registerChatService
inline void registerChatService(
BMXChatService * service
)
注册BMXChatServiceListener绑定到的BMXChatService(SDK内部自动注册)
Parameters:
- service BMXChatService
Protected Attributes Documentation
variable mService
BMXChatService * mService;
Example:
Updated on 2022-01-26 at 17:20:40 +0800