floo::BMXMessage

消息

#include <bmx_message.h>

Inherits from BMXBaseObject

Public Types

Name
enum class DeliveryStatus { New, Delivering, Deliveried, Failed, Recalled}
消息投递状态
enum class MessageType { Single, Group, System}
消息类型
enum class ContentType { Text, Image, Voice, Video, File, Location, Command, Forward}
消息内容类型
enum class DeliveryQos { AtLastOnce, AtMostOnce, ExactlyOnce}
消息投递质量

Public Functions

Name
virtual ~BMXMessage()
析构函数
int64_t msgId()
消息唯一ID
int64_t clientMsgId()
消息客户端ID,仅在消息发送端存在
int64_t fromId()
消息发送方ID
int64_t toId()
消息接收方ID
MessageType type()
消息类型
int64_t conversationId()
消息所属会话ID
DeliveryStatus deliveryStatus()
消息投递状态
void setDeliveryStatus(DeliveryStatus )
设置消息投递状态
int64_t serverTimestamp()
消息时间戳(服务端收到时的时间)
void setServerTimestamp(int64_t )
设置时间戳(服务端收到时的时间)
int64_t clientTimestamp()
本地时间戳(消息创建或者收到时的本地时间)
void setClientTimestamp(int64_t )
设置消息本地时间戳
bool isPlayed()
语音或者视频消息是否播放过,仅对收到的音视频消息有效
void setIsPlayed(bool )
设置语音或者视频消息是否播放过,仅对收到的音视频消息有效
bool isPlayAcked()
对于发送方表示是否收到了已播放回执,对于接收方表示是否发送了已播放回执
void setIsPlayAcked(bool )
设置已播放回执
bool isReceiveMsg()
是否接收的消息
void setIsReceiveMsg(bool )
设置是否接收的消息
bool isRead()
消息是否已读标志
void setIsRead(bool )
消息是否已读标志
bool isReadAcked()
对于发送方表示是否收到了已读回执,对于接收方表示是否发送了已读回执
void setIsReadAcked(bool )
设置已读回执
bool isDeliveryAcked()
对于发送方表示消息是否已投递到对方,对于接收方表示是否发送了消息已到达回执
void setIsDeliveryAcked(bool )
设置投递回执
const std::string & content()
消息文本内容
void setContent(const std::string & content)
消息文本内容
ContentType contentType()
消息内容类型,如果带附件就表示附件类型,不带附件就是文本类型
BMXMessageAttachmentPtr attachment()
消息附件,BMXMessage拥有附件的所有权,负责释放
BMXMessageConfigPtr config()
消息的配置信息
void setConfig(BMXMessageConfigPtr )
设置消息配置信息
const JSON & extension()
消息扩展信息
void setExtension(const JSON & )
设置消息扩展信息
DeliveryQos deliveryQos()
消息投递QOS
void setDeliveryQos(DeliveryQos qos)
设置消息投递QOS
const std::string & senderName()
消息发送者的显示名称
void setSenderName(const std::string & senderName)
设置消息的发送者显示名称
int groupAckCount()
群消息已读AckCount数目
void setGroupAckCount(int count)
设置消息已读groupAckCount数目(SDK 内部调用接口,上层不应该调用)
int groupAckUnreadCount()
群消息未读AckCount数目
void setGroupAckUnreadCount(int count)
设置消息未读groupAckCount数目(SDK 内部调用接口,上层不应该调用)
bool groupAckReadAll()
群消息是否全部已读
int groupPlayAckCount()
群消息已播放AckCount数目(仅用于音频/视频附件消息)
void setGroupPlayAckCount(int count)
设置消息已播放groupAckCount数目(SDK 内部调用接口,上层不应该调用)(仅用于音频/视频附件消息)
int groupPlayAckUnreadCount()
群消息未播放AckCount数目(仅用于音频/视频附件消息)
void setGroupPlayAckUnreadCount(int count)
设置消息未播放groupAckCount数目(SDK 内部调用接口,上层不应该调用)(仅用于音频/视频附件消息)
bool groupPlayAckReadAll()
群消息是否全部已播放
void setPriority(int priority)
设置消息的扩散优先级,默认为0。0表示扩散,数字越小扩散的越多。
int priority()
消息的扩散优先级
void setPushMessageMode(bool )
设置消息是否为推送消息。
bool isPushMessage()
消息是否是推送消息
BMXMessagePtr createMessage(int64_t from, int64_t to, MessageType type, int64_t conversationId, const std::string & content)
创建发送文本消息
BMXMessagePtr createMessage(int64_t from, int64_t to, MessageType type, int64_t conversationId, BMXMessageAttachmentPtr attachment)
创建发送附件消息
BMXMessagePtr createCommandMessage(int64_t from, int64_t to, MessageType type, int64_t conversationId, const std::string & content)
创建发送命令消息(命令消息通过content字段或者extension字段存放命令信息)
BMXMessagePtr createMessage(int64_t msgId, int64_t from, int64_t to, MessageType type, int64_t conversationId, const std::string & content, int64_t serverTimestamp)
创建收到的消息
BMXMessagePtr createMessage(int64_t msgId, int64_t from, int64_t to, MessageType type, int64_t conversationId, BMXMessageAttachmentPtr attachment, int64_t serverTimestamp)
创建收到的消息
BMXMessagePtr createCommandMessage(int64_t msgId, int64_t from, int64_t to, MessageType type, int64_t conversationId, const std::string & content, int64_t serverTimestamp)
创建收到的命令消息(命令消息通过content字段或者extension字段存放命令信息)
BMXMessagePtr createForwardMessage(BMXMessagePtr msg, int64_t from, int64_t to, MessageType type, int64_t conversationId)
创建转发消息

Public Types Documentation

enum DeliveryStatus

Enumerator Value Description
New 新创建消息
Delivering 消息投递中
Deliveried 消息已投递
Failed 消息投递失败
Recalled 消息已撤回

消息投递状态

enum MessageType

Enumerator Value Description
Single 单聊消息
Group 群聊消息
System 系统消息

消息类型

enum ContentType

Enumerator Value Description
Text 文本消息
Image 图片消息
Voice 语音消息
Video 视频片段消息
File 文件消息
Location 位置消息
Command 命令消息
Forward 转发消息

消息内容类型

enum DeliveryQos

Enumerator Value Description
AtLastOnce 最少投递一次
AtMostOnce 最多投递一次
ExactlyOnce 仅投递一次

消息投递质量

Public Functions Documentation

function ~BMXMessage

virtual ~BMXMessage()

析构函数

Example:

function msgId

int64_t msgId()

消息唯一ID

Return: int64_t

Example:

mvwaddstr(notifyWindow, 2, 1, std::to_string(msg->msgId()).c_str());

function clientMsgId

int64_t clientMsgId()

消息客户端ID,仅在消息发送端存在

Return: int64_t

Example:

function fromId

int64_t fromId()

消息发送方ID

Return: int64_t

Example:

function toId

int64_t toId()

消息接收方ID

Return: int64_t

Example:

function type

MessageType type()

消息类型

Return: MessageType

Example:

function conversationId

int64_t conversationId()

消息所属会话ID

Return: int64_t

Example:

function deliveryStatus

DeliveryStatus deliveryStatus()

消息投递状态

Return: DeliveryStatus

Example:

switch (msg->deliveryStatus()) {

function setDeliveryStatus

void setDeliveryStatus(
    DeliveryStatus 
)

设置消息投递状态

Example:

function serverTimestamp

int64_t serverTimestamp()

消息时间戳(服务端收到时的时间)

Return: int64_t

Example:

function setServerTimestamp

void setServerTimestamp(
    int64_t 
)

设置时间戳(服务端收到时的时间)

Example:

function clientTimestamp

int64_t clientTimestamp()

本地时间戳(消息创建或者收到时的本地时间)

Return: int64_t

Example:

function setClientTimestamp

void setClientTimestamp(
    int64_t 
)

设置消息本地时间戳

Example:

function isPlayed

bool isPlayed()

语音或者视频消息是否播放过,仅对收到的音视频消息有效

Return: bool

Example:

function setIsPlayed

void setIsPlayed(
    bool 
)

设置语音或者视频消息是否播放过,仅对收到的音视频消息有效

Example:

function isPlayAcked

bool isPlayAcked()

对于发送方表示是否收到了已播放回执,对于接收方表示是否发送了已播放回执

Return: bool

Example:

function setIsPlayAcked

void setIsPlayAcked(
    bool 
)

设置已播放回执

Example:

function isReceiveMsg

bool isReceiveMsg()

是否接收的消息

Return: bool

Example:

function setIsReceiveMsg

void setIsReceiveMsg(
    bool 
)

设置是否接收的消息

Example:

function isRead

bool isRead()

消息是否已读标志

Return: bool

Example:

function setIsRead

void setIsRead(
    bool 
)

消息是否已读标志

Example:

function isReadAcked

bool isReadAcked()

对于发送方表示是否收到了已读回执,对于接收方表示是否发送了已读回执

Return: bool

Example:

function setIsReadAcked

void setIsReadAcked(
    bool 
)

设置已读回执

Example:

function isDeliveryAcked

bool isDeliveryAcked()

对于发送方表示消息是否已投递到对方,对于接收方表示是否发送了消息已到达回执

Return: bool

Example:

function setIsDeliveryAcked

void setIsDeliveryAcked(
    bool 
)

设置投递回执

Example:

function content

const std::string & content()

消息文本内容

Return: std::string

Example:

mvwaddstr(notifyWindow, 4, 1, msg->content().c_str());

function setContent

void setContent(
    const std::string & content
)

消息文本内容

Parameters:

  • content 消息文本内容

Example:

function contentType

ContentType contentType()

消息内容类型,如果带附件就表示附件类型,不带附件就是文本类型

Return: ContentType

Example:

function attachment

BMXMessageAttachmentPtr attachment()

消息附件,BMXMessage拥有附件的所有权,负责释放

Return: BMXMessageAttachmentPtr

Example:

function config

BMXMessageConfigPtr config()

消息的配置信息

Return: JSON(std::string)

Example:

function setConfig

void setConfig(
    BMXMessageConfigPtr 
)

设置消息配置信息

Example:

function extension

const JSON & extension()

消息扩展信息

Return: JSON(std::string)

Example:

function setExtension

void setExtension(
    const JSON & 
)

设置消息扩展信息

Example:

function deliveryQos

DeliveryQos deliveryQos()

消息投递QOS

Return: DeliveryQos

Example:

function setDeliveryQos

void setDeliveryQos(
    DeliveryQos qos
)

设置消息投递QOS

Parameters:

  • qos 消息投递QOS

Example:

function senderName

const std::string & senderName()

消息发送者的显示名称

Return: std::string

Example:

function setSenderName

void setSenderName(
    const std::string & senderName
)

设置消息的发送者显示名称

Parameters:

  • senderName 消息文本内容

Example:

function groupAckCount

int groupAckCount()

群消息已读AckCount数目

Return: int

Example:

function setGroupAckCount

void setGroupAckCount(
    int count
)

设置消息已读groupAckCount数目(SDK 内部调用接口,上层不应该调用)

Parameters:

  • count 设置群消息已读数目

Example:

function groupAckUnreadCount

int groupAckUnreadCount()

群消息未读AckCount数目

Return: int

Example:

function setGroupAckUnreadCount

void setGroupAckUnreadCount(
    int count
)

设置消息未读groupAckCount数目(SDK 内部调用接口,上层不应该调用)

Parameters:

  • count 设置群消息未读数目

Example:

function groupAckReadAll

bool groupAckReadAll()

群消息是否全部已读

Return: bool

Example:

function groupPlayAckCount

int groupPlayAckCount()

群消息已播放AckCount数目(仅用于音频/视频附件消息)

Return: int

Example:

function setGroupPlayAckCount

void setGroupPlayAckCount(
    int count
)

设置消息已播放groupAckCount数目(SDK 内部调用接口,上层不应该调用)(仅用于音频/视频附件消息)

Parameters:

  • count 设置群消息已读数目

Example:

function groupPlayAckUnreadCount

int groupPlayAckUnreadCount()

群消息未播放AckCount数目(仅用于音频/视频附件消息)

Return: int

Example:

function setGroupPlayAckUnreadCount

void setGroupPlayAckUnreadCount(
    int count
)

设置消息未播放groupAckCount数目(SDK 内部调用接口,上层不应该调用)(仅用于音频/视频附件消息)

Parameters:

  • count 设置群消息未播放数目

Example:

function groupPlayAckReadAll

bool groupPlayAckReadAll()

群消息是否全部已播放

Return: bool

Example:

function setPriority

void setPriority(
    int priority
)

设置消息的扩散优先级,默认为0。0表示扩散,数字越小扩散的越多。

Parameters:

  • priority 设置群消息未读数目

取值范围0-10。普通人在聊天室发送的消息级别默认为5,可以丢弃。管理员默认为0不会丢弃。其它值可以根据业务自行设置。

Example:

function priority

int priority()

消息的扩散优先级

Return: int

Example:

function setPushMessageMode

void setPushMessageMode(
    bool 
)

设置消息是否为推送消息。

Example:

function isPushMessage

bool isPushMessage()

消息是否是推送消息

Return: bool

Example:

function createMessage

static BMXMessagePtr createMessage(
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId,
    const std::string & content
)

创建发送文本消息

Parameters:

  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id
  • content 消息内容

Example:

BMXMessagePtr msg = BMXMessage::createMessage(profile->userId(), toId, (BMXMessage::MessageType)type, toId, params[2]);

function createMessage

static BMXMessagePtr createMessage(
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId,
    BMXMessageAttachmentPtr attachment
)

创建发送附件消息

Parameters:

  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id
  • attachment 附件

Example:

BMXMessagePtr msg = BMXMessage::createMessage(profile->userId(), toId, (BMXMessage::MessageType)type, toId, params[2]);

function createCommandMessage

static BMXMessagePtr createCommandMessage(
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId,
    const std::string & content
)

创建发送命令消息(命令消息通过content字段或者extension字段存放命令信息)

Parameters:

  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id
  • content 消息内容

Example:

function createMessage

static BMXMessagePtr createMessage(
    int64_t msgId,
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId,
    const std::string & content,
    int64_t serverTimestamp
)

创建收到的消息

Parameters:

  • msgId 消息id
  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id
  • content 消息内容
  • serverTimestamp 服务器时间戳

Example:

BMXMessagePtr msg = BMXMessage::createMessage(profile->userId(), toId, (BMXMessage::MessageType)type, toId, params[2]);

function createMessage

static BMXMessagePtr createMessage(
    int64_t msgId,
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId,
    BMXMessageAttachmentPtr attachment,
    int64_t serverTimestamp
)

创建收到的消息

Parameters:

  • msgId 消息id
  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id
  • attachment 附件
  • serverTimestamp 服务器时间戳

Example:

BMXMessagePtr msg = BMXMessage::createMessage(profile->userId(), toId, (BMXMessage::MessageType)type, toId, params[2]);

function createCommandMessage

static BMXMessagePtr createCommandMessage(
    int64_t msgId,
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId,
    const std::string & content,
    int64_t serverTimestamp
)

创建收到的命令消息(命令消息通过content字段或者extension字段存放命令信息)

Parameters:

  • msgId 消息id
  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id
  • content 消息内容
  • serverTimestamp 服务器时间戳

Example:

function createForwardMessage

static BMXMessagePtr createForwardMessage(
    BMXMessagePtr msg,
    int64_t from,
    int64_t to,
    MessageType type,
    int64_t conversationId
)

创建转发消息

Parameters:

  • msg 要转发的消息
  • from 消息发送者
  • to 消息接收者
  • type 消息类型
  • conversationId 会话id

Example:


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

© 2019-2023 美信拓扑 | 官网 该文件修订时间: 2023-08-09 14:48:15

results matching ""

    No results matching ""