floo::BMXChatServiceListener

Chat listener

#include <bmx_chat_service_listener.h>

Public Functions

Name
BMXChatServiceListener()
Constructor
virtual ~BMXChatServiceListener()
Destructor
virtual void onStatusChanged(BMXMessagePtr msg, BMXErrorCode error)
Message state changed
virtual void onAttachmentUploadProgressChanged(BMXMessagePtr msg, int percent)
Attachment upload state changed
virtual void onRecallStatusChanged(BMXMessagePtr msg, BMXErrorCode error)
Message recall state changed
virtual void onReceive(const BMXMessageList & list)
Messages received
virtual void onReceiveCommandMessages(const BMXMessageList & list)
Command received
virtual void onReceiveSystemMessages(const BMXMessageList & list)
System notification messages received
virtual void onReceiveReadAcks(const BMXMessageList & list)
Read acknowledgement of messages received
virtual void onReceiveDeliverAcks(const BMXMessageList & list)
Acknowledgement of message delivered received
virtual void onReceiveRecallMessages(const BMXMessageList & list)
Canceled messages received
virtual void onReceiveReadCancels(const BMXMessageList & list)
Message re-unread received (cross-device synchronization for changing message status into unread)
virtual void onReceiveReadAllMessages(const BMXMessageList & list)
All received messages are read (all messages are set to read before cross-device synchronization)
virtual void onReceiveDeleteMessages(const BMXMessageList & list)
Message deletions received (delete messages cross devices synchronously)
virtual void onReceivePlayAcks(const BMXMessageList & list)
Received acknowledgement of audio/video message playback
virtual void onAttachmentStatusChanged(BMXMessagePtr msg, BMXErrorCode error, int percent)
Attachment download state changed
virtual void onAttachmentDownloadByUrlStatusChanged(int64_t msgId, BMXErrorCode error, int percent)
Attachment download state changed
virtual void onRetrieveHistoryMessages(BMXConversationPtr conversation)
Pull message history
virtual void onLoadAllConversation()
List of unread conversations has been loaded
virtual void onConversationCreate(BMXConversationPtr conversation, BMXMessagePtr msg)
Create a new conversation locally
virtual void onConversationDelete(int64_t conversationId, BMXErrorCode error)
Delete a conversation
virtual void onTotalUnreadCountChanged(int unreadCount)
Update total number of unread messages
void registerChatService(BMXChatService * service)
Register BMXChatService to which BMXChatServiceListener is bound (automatic registration in SDK)

Protected Attributes

Name
BMXChatService * mService

Public Functions Documentation

function BMXChatServiceListener

inline BMXChatServiceListener()

Constructor

Example:

function ~BMXChatServiceListener

inline virtual ~BMXChatServiceListener()

Destructor

Example:

function onStatusChanged

inline virtual void onStatusChanged(
    BMXMessagePtr msg,
    BMXErrorCode error
)

Message state changed

Parameters:

  • msg Message with state changed
  • error State error code

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
)

Attachment upload state changed

Parameters:

  • msg Message for uploading attachment
  • percent Progress of attachment uploading

Example:

function onRecallStatusChanged

inline virtual void onRecallStatusChanged(
    BMXMessagePtr msg,
    BMXErrorCode error
)

Message recall state changed

Parameters:

  • msg Message with state change canceled
  • error State error code

Example:

function onReceive

inline virtual void onReceive(
    const BMXMessageList & list
)

Messages received

Parameters:

  • list List of received messages

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
)

Command received

Parameters:

  • list List of received messages

Example:

function onReceiveSystemMessages

inline virtual void onReceiveSystemMessages(
    const BMXMessageList & list
)

System notification messages received

Parameters:

  • list List of received system messages

Example:

function onReceiveReadAcks

inline virtual void onReceiveReadAcks(
    const BMXMessageList & list
)

Read acknowledgement of messages received

Parameters:

  • list List of received messages with read acknowledgement

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
)

Acknowledgement of message delivered received

Parameters:

  • list List of received messages with delivered acknowledgement

Example:

function onReceiveRecallMessages

inline virtual void onReceiveRecallMessages(
    const BMXMessageList & list
)

Canceled messages received

Parameters:

  • list List of canceled messages received

Example:

function onReceiveReadCancels

inline virtual void onReceiveReadCancels(
    const BMXMessageList & list
)

Message re-unread received (cross-device synchronization for changing message status into unread)

Parameters:

  • list List of received messages with re-unread acknowledgement

Example:

function onReceiveReadAllMessages

inline virtual void onReceiveReadAllMessages(
    const BMXMessageList & list
)

All received messages are read (all messages are set to read before cross-device synchronization)

Parameters:

  • list List of received messages with all-read acknowledgement

Example:

function onReceiveDeleteMessages

inline virtual void onReceiveDeleteMessages(
    const BMXMessageList & list
)

Message deletions received (delete messages cross devices synchronously)

Parameters:

  • list List of deleted messages received

Example:

function onReceivePlayAcks

inline virtual void onReceivePlayAcks(
    const BMXMessageList & list
)

Received acknowledgement of audio/video message playback

Parameters:

  • list List of received audio/video messages with playback acknowledgement

Example:

function onAttachmentStatusChanged

inline virtual void onAttachmentStatusChanged(
    BMXMessagePtr msg,
    BMXErrorCode error,
    int percent
)

Attachment download state changed

Parameters:

  • msg Message with downloading state changed
  • error State error code
  • percent Progress of attachment downloading

Example:

function onAttachmentDownloadByUrlStatusChanged

inline virtual void onAttachmentDownloadByUrlStatusChanged(
    int64_t msgId,
    BMXErrorCode error,
    int percent
)

Attachment download state changed

Parameters:

  • msgId Message ID with downloading state changed
  • error State error code
  • percent Progress of attachment downloading

Example:

function onRetrieveHistoryMessages

inline virtual void onRetrieveHistoryMessages(
    BMXConversationPtr conversation
)

Pull message history

Parameters:

  • conversation Conversation for which a specific message history was pulled

Example:

function onLoadAllConversation

inline virtual void onLoadAllConversation()

List of unread conversations has been loaded

Example:

function onConversationCreate

inline virtual void onConversationCreate(
    BMXConversationPtr conversation,
    BMXMessagePtr msg
)

Create a new conversation locally

Parameters:

  • conversation Newly created local conversation
  • msg Latest message for conversation, return for existing, empty for no existing

Example:

function onConversationDelete

inline virtual void onConversationDelete(
    int64_t conversationId,
    BMXErrorCode error
)

Delete a conversation

Parameters:

  • conversationId Deleted local conversation id
  • error State error code

Example:

function onTotalUnreadCountChanged

inline virtual void onTotalUnreadCountChanged(
    int unreadCount
)

Update total number of unread messages

Parameters:

  • unreadCount Total number of local unread conversations

Example:

function registerChatService

inline void registerChatService(
    BMXChatService * service
)

Register BMXChatService to which BMXChatServiceListener is bound (automatic registration in SDK)

Parameters:

Protected Attributes Documentation

variable mService

BMXChatService * mService;

Example:


Updated on 2022-01-26 at 17:20:40 +0800

© 2019-2023 MaximTop | Homepage Last modified time: 2023-08-09 14:48:15

results matching ""

    No results matching ""