LANYINGDevelopers
Web & Mini ProgramiOSAndroidC++Server API

floo::BMXChatService#

Chat Service

#include <bmx_chat_service.h>

Public Types#

Name
enum classThumbnailStrategy { ThirdpartyServerCreate = 1, LocalServerCreate}
Thumbnail generation policy,

Public Functions#

Name
virtual~BMXChatService()
virtual voidsendMessage(BMXMessagePtr msg) =0
Send a message, and the message status change is notified via listener
virtual voidresendMessage(BMXMessagePtr msg) =0
Resend this message, and the message status change is notified via listener
virtual voidrecallMessage(BMXMessagePtr msg) =0
Recall a message, and the message status change is notified via listener
virtual BMXErrorCodeforwardMessage(const BMXMessageList & list, BMXConversationPtr to, BMXMessagePtr & newMsg) =0
Merge and forward messages
virtual voidforwardMessage(BMXMessagePtr msg) =0
Simple forwarding messages, users should create forwarding messages first through BMXMessage:: createForwardMessage ()
virtual voidackMessage(BMXMessagePtr msg) =0
Send read acknowledgement
virtual voidackMessageDelivered(BMXMessagePtr msg) =0
Send delivery acknowledgement
virtual voidackPlayMessage(BMXMessagePtr msg) =0
Send an audio/video message playback acknowledgement
virtual voidreadCancel(BMXMessagePtr msg) =0
Mark this message as unread and synchronize to all devices of the current user
virtual voidreadAllMessage(BMXMessagePtr msg) =0
Mark this message and all previous messages as read, and synchronize to all current users' devices
virtual voidremoveMessage(BMXMessagePtr msg, bool synchronize =true) =0
Delete this message, which synchronizes to other devices of the current user
virtual voiddownloadThumbnail(BMXMessagePtr msg, ThumbnailStrategy strategy =ThumbnailStrategy::ThirdpartyServerCreate) =0
Download thumbnail, downloading state changes and progress notified via listener. Thumbnail generation policy: 1 - generated by third-party server, 2 - generated by local server, default 1.
virtual voiddownloadAttachment(BMXMessagePtr msg) =0
Downloaded attachments, and download state changes and progress are notified via listener
virtual voiddownloadAttachmentByUrl(int64_t msgId, const std::string & url, const std::string & path) =0
Downloaded attachments, and download state changes and progress are notified via listener
virtual voidcancelUploadAttachment(BMXMessagePtr msg) =0
Cancel uploading attachment
virtual voidcancelDownloadAttachment(BMXMessagePtr msg) =0
Cancel attachment downloading
virtual inttransferingNum() =0
Number of uploading/downloading files
virtual BMXErrorCodeinsertMessages(const BMXMessageList & list) =0
Insert a message
virtual BMXMessagePtrgetMessage(int64_t msgId) =0
Read a message
virtual voiddeleteConversation(int64_t conversationId, bool synchronize =false) =0
Delete a conversation
virtual BMXConversationPtropenConversation(int64_t conversationId, BMXConversation::Type type, bool createIfNotExist =true) =0
Launch a conversation
virtual std::stringattachmentDir() =0
Get attachment saving path
virtual std::stringattachmentDirForConversation(int64_t conversationId) =0
Get attachment saving path for a conversation
virtual BMXConversationListgetAllConversations() =0
Get all conversations
virtual intgetAllConversationsUnreadCount() =0
Get number of unread messages for all conversations (unreads for individuals and groups marked as blocked is not counted)
virtual BMXErrorCoderetrieveHistoryMessages(BMXConversationPtr conversation, int64_t refMsgId, size_t size, BMXMessageList & result) =0
Pull message history
virtual BMXErrorCodesearchMessagesByKeyWords(const std::string & keywords, int64_t refTime, size_t size, std::vector< BMXMessageList > & result, BMXConversation::Direction =BMXConversation::Direction::Up) =0
Search for messages by keyword
virtual BMXErrorCodesearchMessages(const std::string & keywords, int64_t refTime, size_t size, std::vector< BMXMessageList > & result, BMXConversation::Direction =BMXConversation::Direction::Up) =0
Deprecated.
virtual BMXErrorCodegetGroupAckMessageUserIdList(BMXMessagePtr msg, std::vector< int64_t > & groupMemberIdList) =0
Get the list of user-ids that have read group messages
virtual BMXErrorCodegetGroupAckMessageUnreadUserIdList(BMXMessagePtr msg, std::vector< int64_t > & groupMemberIdList) =0
Get a list of unread user ids for the sent group message
virtual BMXErrorCodegetGroupPlayAckMessageUserIdList(BMXMessagePtr msg, std::vector< int64_t > & groupMemberIdList) =0
Get the user id list for sent group audio/video messages played (for audio/video messages only)
virtual BMXErrorCodegetGroupUnPlayAckMessageUserIdList(BMXMessagePtr msg, std::vector< int64_t > & groupMemberIdList) =0
Get the user id list for sent group audio/video messages unplayed (for audio/video messages only)
virtual voidaddChatListener(BMXChatServiceListener * listener) =0
Add chat listener
virtual voidremoveChatListener(BMXChatServiceListener * listener) =0
Remove chat listener

Protected Functions#

Name
BMXChatService()
voidupdateMessageId(BMXMessagePtr msg, int64_t newId)

Public Types Documentation#

enum ThumbnailStrategy#

EnumeratorValueDescription
ThirdpartyServerCreate1Generated by third-party server
LocalServerCreateGenerated by local server

Thumbnail generation policy,

Public Functions Documentation#

function ~BMXChatService#

inline virtual ~BMXChatService()

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="~BMXChatService" %}{% endlanying_code_snippet %}

function sendMessage#

virtual void sendMessage(
    BMXMessagePtr msg
) =0

Send a message, and the message status change is notified via listener

Parameters:

  • msg Message to be sent

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="sendMessage" %}{% endlanying_code_snippet %}

function resendMessage#

virtual void resendMessage(
    BMXMessagePtr msg
) =0

Resend this message, and the message status change is notified via listener

Parameters:

  • msg Resent message

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="resendMessage" %}{% endlanying_code_snippet %}

function recallMessage#

virtual void recallMessage(
    BMXMessagePtr msg
) =0

Recall a message, and the message status change is notified via listener

Parameters:

  • msg Recalled message

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="recallMessage" %}{% endlanying_code_snippet %}

function forwardMessage#

virtual BMXErrorCode forwardMessage(
    const BMXMessageList & list,
    BMXConversationPtr to,
    BMXMessagePtr & newMsg
) =0

Merge and forward messages

Parameters:

  • list List of messages to be forwarded
  • to The conversation to which message is forwarded
  • newMsg The newly generated single forwarded message from the merging list of messages to be forwarded

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="forwardMessage" %}{% endlanying_code_snippet %}

function forwardMessage#

virtual void forwardMessage(
    BMXMessagePtr msg
) =0

Simple forwarding messages, users should create forwarding messages first through BMXMessage:: createForwardMessage ()

Parameters:

  • msg Messages to be forwarded

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="forwardMessage" %}{% endlanying_code_snippet %}

function ackMessage#

virtual void ackMessage(
    BMXMessagePtr msg
) =0

Send read acknowledgement

Parameters:

  • msg Message requiring a read acknowledgement to be sent

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="ackMessage" %}{% endlanying_code_snippet %}

function ackMessageDelivered#

virtual void ackMessageDelivered(
    BMXMessagePtr msg
) =0

Send delivery acknowledgement

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="ackMessageDelivered" %}{% endlanying_code_snippet %}

function ackPlayMessage#

virtual void ackPlayMessage(
    BMXMessagePtr msg
) =0

Send an audio/video message playback acknowledgement

Parameters:

  • msg Message requiring a read acknowledgement to be sent

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="ackPlayMessage" %}{% endlanying_code_snippet %}

function readCancel#

virtual void readCancel(
    BMXMessagePtr msg
) =0

Mark this message as unread and synchronize to all devices of the current user

Parameters:

  • msg The message needs to send “read recalled”

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="readCancel" %}{% endlanying_code_snippet %}

function readAllMessage#

virtual void readAllMessage(
    BMXMessagePtr msg
) =0

Mark this message and all previous messages as read, and synchronize to all current users' devices

Parameters:

  • msg The message for which all earlier messages need to be marked as read

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="readAllMessage" %}{% endlanying_code_snippet %}

function removeMessage#

virtual void removeMessage(
    BMXMessagePtr msg,
    bool synchronize =true
) =0

Deletes the message and synchronises the deletion to the current user's other devices

Parameters:

  • msg Message to be deleted
  • synchronize Whether to synchronize to other devices, otherwise only the locally stored message will be deleted

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="removeMessage" %}{% endlanying_code_snippet %}

function downloadThumbnail#

virtual void downloadThumbnail(
    BMXMessagePtr msg,
    ThumbnailStrategy strategy =ThumbnailStrategy::ThirdpartyServerCreate
) =0

Download thumbnail, downloading state changes and progress notified via listener. Thumbnail generation policy: 1 - generated by third-party server, 2 - generated by local server, default 1.

Parameters:

  • msg Message requiring to download thumbnail
  • strategy Thumbnail generation policy, 1 - generated by third-party server, 2 - Generated by local server, default 1.

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="downloadThumbnail" %}{% endlanying_code_snippet %}

function downloadAttachment#

virtual void downloadAttachment(
    BMXMessagePtr msg
) =0

Downloaded attachments, and download state changes and progress are notified via listener

Parameters:

  • msg Message requiring to download attachment

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="downloadAttachment" %}{% endlanying_code_snippet %}

function downloadAttachmentByUrl#

virtual void downloadAttachmentByUrl(
    int64_t msgId,
    const std::string & url,
    const std::string & path
) =0

Downloaded attachments, and download state changes and progress are notified via listener

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="downloadAttachmentByUrl" %}{% endlanying_code_snippet %}

function cancelUploadAttachment#

virtual void cancelUploadAttachment(
    BMXMessagePtr msg
) =0

Cancel uploading attachment

Parameters:

  • msg Message requiring to cancel attachment uploading

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="cancelUploadAttachment" %}{% endlanying_code_snippet %}

function cancelDownloadAttachment#

virtual void cancelDownloadAttachment(
    BMXMessagePtr msg
) =0

Cancel attachment downloading

Parameters:

  • msg Message requiring to cancel attachment downloading

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="cancelDownloadAttachment" %}{% endlanying_code_snippet %}

function transferingNum#

virtual int transferingNum() =0

Number of uploading/downloading files

Return: Number of files

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="transferingNum" %}{% endlanying_code_snippet %}

function insertMessages#

virtual BMXErrorCode insertMessages(
    const BMXMessageList & list
) =0

Insert a message

Parameters:

  • list Insert message list

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="insertMessages" %}{% endlanying_code_snippet %}

function getMessage#

virtual BMXMessagePtr getMessage(
    int64_t msgId
) =0

Read a message

Parameters:

  • msgId id of the message which needs to be fetched

Return: BMXMessagePtr

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getMessage" %}{% endlanying_code_snippet %}

function deleteConversation#

virtual void deleteConversation(
    int64_t conversationId,
    bool synchronize =false
) =0

Delete a conversation

Parameters:

  • conversationId Conversation id requiring to delete conversation
  • synchronize Whether to delete the conversation on other devices synchronously, default false, means only delete the conversation on the current device

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="deleteConversation" %}{% endlanying_code_snippet %}

function openConversation#

virtual BMXConversationPtr openConversation(
    int64_t conversationId,
    BMXConversation::Type type,
    bool createIfNotExist =true
) =0

Launch a conversation

Parameters:

  • conversationId id of the conversation which needs to be opened
  • type Conversation type, single/group chat.
  • createIfNotExist Whether to create a local conversation if no conversation existing, default to create

Return: BMXConversationPtr

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="openConversation" %}{% endlanying_code_snippet %}

function attachmentDir#

virtual std::string attachmentDir() =0

Get attachment saving path

Return: std::string

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="attachmentDir" %}{% endlanying_code_snippet %}

function attachmentDirForConversation#

virtual std::string attachmentDirForConversation(
    int64_t conversationId
) =0

Get attachment saving path for a conversation

Parameters:

  • conversationId Conversation id requiring a conversation attachment path

Return: std::string

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="attachmentDirForConversation" %}{% endlanying_code_snippet %}

function getAllConversations#

virtual BMXConversationList getAllConversations() =0

Get all conversations

Return: BMXConversationList

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getAllConversations" %}{% endlanying_code_snippet %}

function getAllConversationsUnreadCount#

virtual int getAllConversationsUnreadCount() =0

Get number of unread messages for all conversations (unreads for individuals and groups marked as blocked is not counted)

Return: int

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getAllConversationsUnreadCount" %}{% endlanying_code_snippet %}

function retrieveHistoryMessages#

virtual BMXErrorCode retrieveHistoryMessages(
    BMXConversationPtr conversation,
    int64_t refMsgId,
    size_t size,
    BMXMessageList & result
) =0

Message history retrieved

Parameters:

  • conversation Conversation for which message history needs to pull
  • refMsgId Start message Id for pulling conversation messages
  • size Maximum number of messages to pull
  • result List of messages fetched by pull operation, externally initializing an incoming empty list.

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="retrieveHistoryMessages" %}{% endlanying_code_snippet %}

function searchMessagesByKeyWords#

virtual BMXErrorCode searchMessagesByKeyWords(
    const std::string & keywords,
    int64_t refTime,
    size_t size,
    std::vector< BMXMessageList > & result,
    BMXConversation::Direction  =BMXConversation::Direction::Up
) =0

Search for messages by keyword

Parameters:

  • keywords Keyword for search
  • refTime Start time of message search
  • size Maximum number of messages to search
  • result List of searched message results, externally initializing an incoming empty list.
  • Direction Message search direction, default (Direction::Up)means search from earlier messages.

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="searchMessagesByKeyWords" %}{% endlanying_code_snippet %}

function searchMessages#

virtual BMXErrorCode searchMessages(
    const std::string & keywords,
    int64_t refTime,
    size_t size,
    std::vector< BMXMessageList > & result,
    BMXConversation::Direction  =BMXConversation::Direction::Up
) =0

Deprecated.

Parameters:

  • keywords Keyword for search
  • refTime Start time of message search
  • size Maximum number of messages to search
  • result List of searched message results, externally initializing an incoming empty list.
  • Direction Message search direction, default (Direction::Up)means search from earlier messages.

Return: BMXErrorCode

use searchMessagesByKeyWords instead.

Search for messages

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="searchMessages" %}{% endlanying_code_snippet %}

function getGroupAckMessageUserIdList#

virtual BMXErrorCode getGroupAckMessageUserIdList(
    BMXMessagePtr msg,
    std::vector< int64_t > & groupMemberIdList
) =0

Get the list of user-ids that have read group messages

Parameters:

  • msg Message requiring to get list of read user ids
  • groupMemberIdList List of read user ids for this message, initially passed in as an empty list

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getGroupAckMessageUserIdList" %}{% endlanying_code_snippet %}

function getGroupAckMessageUnreadUserIdList#

virtual BMXErrorCode getGroupAckMessageUnreadUserIdList(
    BMXMessagePtr msg,
    std::vector< int64_t > & groupMemberIdList
) =0

Get a list of unread user ids for the sent group message

Parameters:

  • msg Message requiring to get list of unread user ids
  • groupMemberIdList List of unread user ids for this message, initially passed in as an empty list

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getGroupAckMessageUnreadUserIdList" %}{% endlanying_code_snippet %}

function getGroupPlayAckMessageUserIdList#

virtual BMXErrorCode getGroupPlayAckMessageUserIdList(
    BMXMessagePtr msg,
    std::vector< int64_t > & groupMemberIdList
) =0

Get the user id list for sent group audio/video messages played (for audio/video messages only)

Parameters:

  • msg Message requiring to get list of played user ids
  • groupMemberIdList List of played user ids for this message, initially passed in as an empty list

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getGroupPlayAckMessageUserIdList" %}{% endlanying_code_snippet %}

function getGroupUnPlayAckMessageUserIdList#

virtual BMXErrorCode getGroupUnPlayAckMessageUserIdList(
    BMXMessagePtr msg,
    std::vector< int64_t > & groupMemberIdList
) =0

Get the user id list for sent group audio/video messages unplayed (for audio/video messages only)

Parameters:

  • msg Message requiring to get list of unplayed user ids
  • groupMemberIdList List of unplayed user ids for this message, initially passed in as an empty list

Return: BMXErrorCode

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="getGroupUnPlayAckMessageUserIdList" %}{% endlanying_code_snippet %}

function addChatListener#

virtual void addChatListener(
    BMXChatServiceListener * listener
) =0

Add chat listener

Parameters:

  • listener Chat listener

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="addChatListener" %}{% endlanying_code_snippet %}

function removeChatListener#

virtual void removeChatListener(
    BMXChatServiceListener * listener
) =0

Remove chat listener

Parameters:

  • listener Chat listener

Protected Functions Documentation#

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="removeChatListener" %}{% endlanying_code_snippet %}

function BMXChatService#

inline BMXChatService()

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="BMXChatService" %}{% endlanying_code_snippet %}

function updateMessageId#

void updateMessageId(
    BMXMessagePtr msg,
    int64_t newId
)

Example:

{% lanying_code_snippet repo="lanying-im-embedded",class="BMXChatService",function="updateMessageId" %}{% endlanying_code_snippet %}

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

Generated API content with concise AI notes where context helps.