Message 类(Flutter IMLib)

类继承图​

Object→Message

继承关系:Object → Message。该数据结构不包含行为方法,字段与 domain.json → schemas.Message 一一对应。

类说明​

消息实体。收发消息、历史消息、搜索、撤回等接口的核心数据结构;seq 由服务端分配,用于会话内排序与分页。rev23 起可选 channelId 表示超级群频道消息(为空即群级消息)。

rev23:channelId 与频道消息

超级群(conversationType=10)消息可带 channelId:仅频道成员接收、历史按频道过滤;sendMessage/getHistoryMessages 通过 options.channelId 指定。路由与权限详见「超级群频道级消息」。

项值
类型数据结构(值对象)
字段数10
IDL 定义domain.json → schemas.Message
程序包impaas_imlib
跨端一致性字段名与取值在 7 个平台绑定中一致;仅语言类型映射不同
平台状态已交付

字段概要​

字段类型必填说明
messageIdstring是消息 ID(服务端生成;客户端只读)
clientMsgIdstring否客户端消息 ID:发送幂等键,10 分钟内同用户重复使用返回首次结果
conversationTypeConversationType是会话类型,见 ConversationType
targetIdstring是目标 ID(userId / groupId / chatroomId / system)
channelIdstring否超级群频道 ID(IDL rev23):conversationType=SUPER_GROUP 时可指定;仅该频道成员接收,历史按 channelId 过滤;为空表示群级消息。
senderIdstring是发送者 userId
sequint64是会话内单调递增,服务端分配
timestampint64是epoch ms
contentContent是消息内容体,见 MessageContent
directionDirection是消息方向,见 Direction

详细字段说明​

string messageId
必填

消息 ID(服务端生成;客户端只读)

string clientMsgId
可选

客户端消息 ID:发送幂等键,10 分钟内同用户重复使用返回首次结果

ConversationType conversationType
必填

会话类型,见 ConversationType

string targetId
必填

目标 ID(userId / groupId / chatroomId / system)

string channelId
可选自 1.6.0

超级群频道 ID(IDL rev23):conversationType=SUPER_GROUP 时可指定;仅该频道成员接收,历史按 channelId 过滤;为空表示群级消息。

string senderId
必填

发送者 userId

uint64 seq
必填

会话内单调递增,服务端分配

int64 timestamp
必填

epoch ms

Content content
必填

消息内容体,见 MessageContent

Direction direction
必填

消息方向,见 Direction

相关链接​