Class MsgStore

Mobx 可观察对象,负责管理会话消息的子 store

Hierarchy

  • MsgStore

Constructors

Properties

msgs: QueueMap<IMMessage> = ...
replyMsgs: Map<string, IMMessage> = ...

回复消息

Methods

  • MsgStore添加消息处理函数(MsgStore内部使用,外层不太推荐直接使用)

    Parameters

    • sessionId: string

      消息所属的会话的ID

    • msgs: IMMessage[]

    Returns void

  • 插入一条对方撤回的自定义消息

    Parameters

    • __namedParameters: {
          from: string;
          idClient: string;
          scene: "p2p" | "team" | "superTeam";
          time: number;
          to: string;
      }
      • from: string

        消息发送方帐号

      • idClient: string

        端测生成的消息id, 可作为消息唯一主键使用

      • scene: "p2p" | "team" | "superTeam"

        场景

      • time: number

        消息发送成功的时间戳(单位毫秒)

      • to: string

        接收方, 对方帐号或者群id

    Returns void

  • 单向删除消息

    Parameters

    Returns Promise<void>

  • 销毁MsgStore,会取消消息相关事件监听

    Returns void

  • 获取历史消息

    Parameters

    • options: {
          endTime: number;
          lastMsgId?: string;
          limit: number;
          sessionId: string;
      }
      • endTime: number

        结束时间戳, 精确到 ms, 默认为服务器的当前时间

      • Optional lastMsgId?: string

        上次查询的最后一条消息的 idServer, 第一次不填

      • limit: number

        本次查询的消息数量限制, 最多 100 条, 默认 100 条

      • sessionId: string

        消息所属的会话的ID

    Returns Promise<IMMessage[]>

  • MsgStore获取消息函数(MsgStore内部使用,外层不太推荐直接使用)

    Parameters

    • Optional sessionId: string

      消息所属的会话的ID

    • Optional idClients: string[]

      端测生成的消息id数组

    Returns IMMessage[]

  • Parameters

    • params: GetMsgsByIdServerOptions

    Returns Promise<IMMessage[]>

  • 撤回消息

    Parameters

    Returns Promise<void>

  • MsgStore删除消息处理函数(MsgStore内部使用,外层不太推荐直接使用)

    Parameters

    • Optional sessionId: string

      消息所属的会话的ID

    • Optional idClients: string[]

      端测生成的消息id数组

    Returns void

  • 回复消息

    Parameters

    • sessionId: string

    Returns void

  • 回复消息

    Parameters

    Returns void

  • 发送自定义消息

    Parameters

    • __namedParameters: {
          attach: string;
          body: string;
          scene: "p2p" | "team" | "superTeam";
          to: string;
      }
      • attach: string

        附件信息

      • body: string

        发送内容

      • scene: "p2p" | "team" | "superTeam"

        场景

      • to: string

        接收方, 对方帐号或者群id

    Returns Promise<IMMessage>

  • 通过 NIMSDK实例 发送自定义消息

    Parameters

    • cb: ((nim) => Promise<IMMessage>)

      调用NIMSDK实例上发送消息接口的回调,参数为NIMSDK实例

    Returns Promise<void>

  • 发送文件消息

    Parameters

    • __namedParameters: {
          file?: File;
          filePath?: string;
          scene: "p2p" | "team" | "superTeam";
          to: string;
      }
      • Optional file?: File

        文件对象

      • Optional filePath?: string

        文件路径

      • scene: "p2p" | "team" | "superTeam"

        场景

      • to: string

        接收方, 对方帐号或者群id

    Returns Promise<IMMessage>

  • 发送图片消息

    Parameters

    • __namedParameters: {
          file?: File;
          filePath?: string;
          scene: "p2p" | "team" | "superTeam";
          to: string;
      }
      • Optional file?: File

        图片对象

      • Optional filePath?: string

        图片路径

      • scene: "p2p" | "team" | "superTeam"

        场景

      • to: string

        接收方, 对方帐号或者群id

    Returns Promise<IMMessage>

  • 发送 p2p 消息已读回执

    Parameters

    Returns Promise<void>

  • 发送文本消息

    Parameters

    • __namedParameters: {
          body: string;
          ext?: Record<string, unknown>;
          scene: "p2p" | "team" | "superTeam";
          to: string;
      }
      • body: string

        发送内容

      • Optional ext?: Record<string, unknown>
      • scene: "p2p" | "team" | "superTeam"

        场景

      • to: string

        接收方, 对方帐号或者群id

    Returns Promise<IMMessage>

Generated using TypeDoc