Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ChannelClient

Index

Constructors

constructor

  • new ChannelClient(_context: APIContext, channelId: string, _isCPPMode: boolean, _readReceiptTimeout: number): ChannelClient
  • Parameters

    • _context: APIContext
    • channelId: string
    • _isCPPMode: boolean
    • _readReceiptTimeout: number

    Returns ChannelClient

Properties

Readonly channelId

channelId: string

Methods

clearConversations

  • clearConversations(callback: ICallback<boolean, void>, conversationTypes: ConversationType[]): void
  • 删除指定类型会话,该方法已弃用

    description

    仅可在协议栈连接下调用

    Parameters

    Returns void

clearMessages

  • clearMessages(conversationType: ConversationType, targetId: string, callback: ICallback<boolean, void>): void
  • 清空会话下历史消息

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • callback: ICallback<boolean, void>

    Returns void

clearRemoteHistoryMessages

  • clearRemoteHistoryMessages(param: IDelteByTime, callback: ICallback<void, void>): void
  • 通过时间戳删除消息

    Parameters

    • param: IDelteByTime
    • callback: ICallback<void, void>

    Returns void

clearTextMessageDraft

  • clearTextMessageDraft(conversationType: ConversationType, targetId: string): boolean
  • 删除草稿

    Parameters

    Returns boolean

clearUnreadCount

  • clearUnreadCount(conversationType: ConversationType, targetId: string, callback: ICallback<boolean, void>): void
  • 清除指定会话未读数

    Parameters

    • conversationType: ConversationType
    • targetId: string
    • callback: ICallback<boolean, void>

    Returns void

clearUnreadCountByTimestamp

  • clearUnreadCountByTimestamp(conversationType: ConversationType, targetId: string, timestamp: number, callback: ICallback<boolean, void>): void
  • 清除时间戳前的未读数

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • timestamp: number

      目标 ID

    • callback: ICallback<boolean, void>

    Returns void

deleteLocalMessagesByTimestamp

  • deleteLocalMessagesByTimestamp(conversationType: ConversationType, targetId: string, timestamp: number, cleanSpace: boolean, callback: ICallback<boolean, void>): void
  • 从本地消息数据库中删除某一会话指定时间之前的消息数据

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • timestamp: number

      指定删除该时间戳之前的消息

    • cleanSpace: boolean

      指定删除该时间戳之前的消息。是否清理数据条目所使用的磁盘空间。清理磁盘空间会阻塞进程且耗时较长,不推荐使用。 数据在被抹除的情况下,未清理的磁盘空间会在后续存储操作中复用,且对数据查询无影响

    • callback: ICallback<boolean, void>

    Returns void

deleteRemoteMessages

  • deleteRemoteMessages(conversationType: ConversationType, targetId: string, messages: IDeleteMessge[], callback: ICallback<void, void>): void
  • 通过 messageUId 删除消息

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      会话 id

    • messages: IDeleteMessge[]

      要删除的消息 []

    • callback: ICallback<void, void>

    Returns void

getConversation

  • 获取指定会话

    deprecated

    Parameters

    Returns void

getConversationList

  • getConversationList(callback: ICallback<IConversation[], void>, conversationTypes: null | Number[], count?: number): void
  • 获取会话列表

    Parameters

    • callback: ICallback<IConversation[], void>

      结果回调

    • conversationTypes: null | Number[]

      会话类型,为 null 时,返回全部会话

    • Optional count: number

      获取数量,默认 300

    Returns void

getConversationNotificationStatus

  • getConversationNotificationStatus(conversationType: ConversationType, targetId: string, callback: ICallback<NotificationStatus, void>): void
  • 获取会话免打扰状态

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • callback: ICallback<NotificationStatus, void>

    Returns void

getFirstUnreadMessage

  • getFirstUnreadMessage(conversationType: ConversationType, targetId: string, callback: ICallback<null | IReceivedMessageV2, void>): void
  • 获取第一个未读消息,仅在协议栈下可调用

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • callback: ICallback<null | IReceivedMessageV2, void>

    Returns void

getHistoryMessages

  • getHistoryMessages(conversationType: ConversationType, targetId: string, timestamp: number, count: number, callback: ICallback<IReceivedMessageV2[], boolean>, objectName?: string, order?: 0 | 1): void
  • 从服务端拉取指定会话的历史消息

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      会话 ID

    • timestamp: number

      获取时间戳, 0 为从当前时间拉取

    • count: number

      拉取条数,获取条数, 范围 1 - 20

    • callback: ICallback<IReceivedMessageV2[], boolean>
    • Optional objectName: string
    • Optional order: 0 | 1

      获取顺序,默认为 0。0 为升序,获取消息发送时间比 timestamp 更早的消息;1 为降序。

    Returns void

getMessageReader

  • getMessageReader(messageUId: string, targetId: string, callback: ICallback<IMessageReaderResponse, void>): void
  • 获取群已读列表

    Parameters

    Returns void

getRemoteHistoryMessages

  • getRemoteHistoryMessages(conversationType: ConversationType, targetId: string, timestamp: number, count: number, callback: ICallback<IReceivedMessageV2[], boolean>, options: { order?: 0 | 1 }): void
  • 协议栈获取远端历史消息

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      会话 ID

    • timestamp: number

      获取时间戳, 0 为从当前时间拉取

    • count: number

      拉取条数,获取条数, 范围 1 - 20

    • callback: ICallback<IReceivedMessageV2[], boolean>
    • options: { order?: 0 | 1 }
      • Optional order?: 0 | 1

    Returns void

getTextMessageDraft

  • getTextMessageDraft(conversationType: ConversationType, targetId: string): undefined | string
  • 获取草稿信息

    description

    未登录或无草稿数据时将返回 undefined

    Parameters

    Returns undefined | string

getTotalUnreadCount

  • getTotalUnreadCount(callback: ICallback<number, void>, conversationTypes?: ConversationType[], includeMuted?: boolean): void
  • 获取当前组织下的所有会话的消息未读数

    description
    1. 清除浏览器缓存会导致会话未读数不准确
    2. 会话消息未读数存储在 WebStorage 中, 若浏览器不支持或禁用 WebStorage,未读消息数将不会保存,浏览器页面刷新未读消息数将不会存在

    Parameters

    • callback: ICallback<number, void>
    • Optional conversationTypes: ConversationType[]

      要获取未读数的会话类型,若为空,则默认获取单聊、群聊及系统消息未读数

    • Optional includeMuted: boolean

      是否包含免打扰会话(web 暂未实现)

    Returns void

getUnreadCount

  • getUnreadCount(conversationType: ConversationType, targetId: string, callback: ICallback<number, void>): void
  • 获取指定会话的消息未读数

    todo

    Parameters

    • conversationType: ConversationType
    • targetId: string
    • callback: ICallback<number, void>

    Returns void

getUnreadMentionedMessages

  • getUnreadMentionedMessages(conversationType: ConversationType, targetId: string): IReceivedMessageV2[]
  • 获取会话下所有未读的 @ 消息

    Parameters

    Returns IReceivedMessageV2[]

insertMessage

  • insertMessage(conversationType: ConversationType, targetId: string, content: IReceivedMessageV2, callback: ICallback<IReceivedMessageV2, void>, options?: IInsertOptions): void
  • 向本地插入一条消息,不发送到服务器

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • content: IReceivedMessageV2

      消息体

    • callback: ICallback<IReceivedMessageV2, void>
    • options: IInsertOptions = {}

    Returns void

removeConversation

  • removeConversation(conversationType: ConversationType, targetId: string, callback: ICallback<void, void>): void
  • 删除指定会话

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      会话 target_id

    • callback: ICallback<void, void>

      删除回调

    Returns void

removeMessageExpansionForKey

  • removeMessageExpansionForKey(keys: string[], message: IReceivedMessageV2, callback: ICallback<void, void>): void
  • 删除消息扩展属性

    Parameters

    • keys: string[]

      消息扩展信息中待删除的 key 的列表

    • message: IReceivedMessageV2

      要删除消息扩展的原始消息体

    • callback: ICallback<void, void>

    Returns void

saveTextMessageDraft

  • saveTextMessageDraft(conversationType: ConversationType, targetId: string, draftText: string): boolean
  • 保存草稿

    description

    草稿存储在内存中,如刷新或者关闭页面会导致草稿丢失。 草稿功能并未在 v3 SDK 版本红实现,由 Bridge 模块实现

    Parameters

    Returns boolean

searchConversationByContent

  • searchConversationByContent(keyword: string, callback: ICallback<IConversation[], void>, conversationTypes?: ConversationType[], customMessageType?: string[]): void
  • 按内容搜索会话

    Parameters

    • keyword: string

      关键字

    • callback: ICallback<IConversation[], void>
    • Optional conversationTypes: ConversationType[]

      会话类型数组

    • Optional customMessageType: string[]

    Returns void

searchMessageByContent

  • searchMessageByContent(conversationType: ConversationType, targetId: string, keyword: string, timestamp: number, count: number, total: number, callback: ICallback<IReceivedMessageV2[], number>): void
  • 按内容搜索会话内容的消息

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      目标 ID

    • keyword: string

      搜索内容

    • timestamp: number

      搜索时间, 搜索该时间之前的消息

    • count: number

      获取的数量

    • total: number
    • callback: ICallback<IReceivedMessageV2[], number>

    Returns void

sendMessage

  • sendMessage(conversationType: ConversationType, targetId: string, msg: BaseMessage<any>, callback: ISendCallback<IReceivedMessageV2, void>, isMentioned?: boolean, pushContent?: string, pushData?: string, options?: ISendOptionsV2): void
  • 发送消息

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      接收方 id,当会话类型为单聊时,该值为单聊对象的 userId,为群聊时,该值应为群组 groupId

    • msg: BaseMessage<any>

      消息体

    • callback: ISendCallback<IReceivedMessageV2, void>

      回调函数

    • Optional isMentioned: boolean

      是否为 @ 消息

    • Optional pushContent: string

      移动端在接收到消息推送时用于显示的推送信息

    • Optional pushData: string

      Push 通知时附加信息

    • Optional options: ISendOptionsV2

      其他设置项

    Returns void

sendReadReceiptMessage

  • sendReadReceiptMessage(messageUIds: string[], targetId: string, callback: ICallback<void, void>): void
  • 发送群已读回执

    Parameters

    • messageUIds: string[]
    • targetId: string
    • callback: ICallback<void, void>

    Returns void

sendRecallMessage

  • sendRecallMessage(message: IReceivedMessageV2, callback: ICallback<IReceivedMessageV2, void>, options?: IRecallOptionsV2): void
  • 消息撤回

    Parameters

    • message: IReceivedMessageV2
    • callback: ICallback<IReceivedMessageV2, void>
    • Optional options: IRecallOptionsV2

    Returns void

sendReceiptResponse

  • sendReceiptResponse(conversationType: ConversationType, targetId: string, callback: ICallback<null | IReceivedMessageV2, void>): void
  • 发送已读回执

    description

    Parameters

    • conversationType: ConversationType
    • targetId: string
    • callback: ICallback<null | IReceivedMessageV2, void>

    Returns void

sendTypingStatusMessage

  • sendTypingStatusMessage(conversationType: ConversationType, targetId: string, typingContentType: string, callback: ICallback<IReceivedMessageV2, void>): void
  • 发送正在输入状态消息

    description

    正在输入状态消息,不存储、不计数、不推送

    Parameters

    • conversationType: ConversationType

      会话类型

    • targetId: string

      会话 id

    • typingContentType: string

      正在输入的消息 ObjectName,如 RC:TxtMsg

    • callback: ICallback<IReceivedMessageV2, void>

    Returns void

setConversationStatus

  • setConversationStatus(conversationType: ConversationType, targetId: string, status: IConversationStatus, callback: ICallback<void, void>): void
  • 设置会话状态:是否置顶、是否免打扰

    Parameters

    • conversationType: ConversationType
    • targetId: string
    • status: IConversationStatus
    • callback: ICallback<void, void>

    Returns void

updateMessageExpansion

  • updateMessageExpansion(expansionDic: {}, message: IReceivedMessageV2, callback: ICallback<void, void>): void
  • 更新消息扩展

    Parameters

    • expansionDic: {}

      要更新的消息扩展信息键值对

      • [key: string]: string
    • message: IReceivedMessageV2

      要更新的原始消息体

    • callback: ICallback<void, void>

    Returns void

Generated using TypeDoc