Options
All
  • Public
  • Public/Protected
  • All
Menu

export class type

Hierarchy

  • ChatConversation

Index

Constructors

  • Parameters

    • params: { convId: string; convType: ChatConversationType; ext?: any; isChatThread?: boolean; isPinned?: boolean; pinnedTime?: number }
      • convId: string
      • convType: ChatConversationType
      • Optional ext?: any
      • Optional isChatThread?: boolean
      • Optional isPinned?: boolean
      • Optional pinnedTime?: number

    Returns ChatConversation

Properties

convId: string

The conversation ID.

The conversation type.

ext?: any

The conversation extension.

isChatThread: boolean

Whether the current conversation is a thread conversation.

  • true: Yes.
  • false: No.

Note

This parameter is valid only for group chat.

isPinned?: boolean

Whether the conversation is pinned:

  • true: Yes.
  • (Default) false: No.
pinnedTime?: number

The UNIX timestamp when the conversation is pinned. The unit is millisecond. This value is 0 when the conversation is not pinned.

Methods

  • deleteAllMessages(): Promise<void>
  • Deletes all the messages of the conversation.

    This method deletes all the messages of the conversation from both the memory and local database.

    throws

    A description of the exception. See ChatError.

    Returns Promise<void>

  • deleteMessage(msgId: string): Promise<void>
  • Deletes a message from the local database.

    throws

    A description of the exception. See ChatError.

    Parameters

    • msgId: string

      The ID of message to delete.

    Returns Promise<void>

  • deleteMessagesWithTimestamp(params: { endTs: number; startTs: number }): Promise<void>
  • Deletes messages sent or received in a certain period from the local database.

    params

    params

    • startTs: The starting UNIX timestamp for message deletion. The unit is millisecond.
    • endTs: The end UNIX timestamp for message deletion. The unit is millisecond.
    throws

    A description of the exception. See ChatError.

    Parameters

    • params: { endTs: number; startTs: number }
      • endTs: number
      • startTs: number

    Returns Promise<void>

  • Uses the pagination to get messages in the specified conversation from the server.

    params

    params

    • pageSize: The number of messages that you expect to get on each page. The value range is [1,50].
    • startMsgId: The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, in the reverse chronological order of when the server receives them. If this parameter is set an empty string, the SDK retrieves messages, starting from the latest one, in the reverse chronological order of when the server receives them.
    • direction: The message search direction. See ChatSearchDirection. - (Default) ChatSearchDirection.Up: Messages are retrieved in the descending order of the Unix timestamp included in them. - ChatSearchDirection.Down: Messages are retrieved in the ascending order of the Unix timestamp included in them.
    throws

    A description of the exception. See ChatError.

    Parameters

    Returns Promise<ChatCursorResult<ChatMessage>>

    The list of retrieved messages (excluding the one with the starting ID) and the cursor for the next query.

  • retrieve the history message for the specified session from the server.

    throws

    A description of the exception. See ChatError.

    Parameters

    • Optional params: { cursor?: string; options?: ChatFetchMessageOptions; pageSize?: number }
      • options: The parameter configuration class for pulling historical messages from the server. See ChatFetchMessageOptions.
      • cursor: The cursor position from which to start querying data.
      • pageSize: The number of messages that you expect to get on each page. The value range is [1,50].

    Returns Promise<ChatCursorResult<ChatMessage>>

    The list of retrieved messages (excluding the one with the starting ID) and the cursor for the next query.

  • Gets the latest message from the conversation.

    throws

    A description of the exception. See ChatError.

    Returns Promise<undefined | ChatMessage>

    The message instance. The SDK returns undefined if the message does not exist.

  • getLatestReceivedMessage(): Promise<undefined | ChatMessage>
  • Gets the latest message received in the conversation.

    throws

    A description of the exception. See ChatError.

    Returns Promise<undefined | ChatMessage>

    The message instance. The SDK returns undefined if the message does not exist.

  • Gets messages that are sent and received in a certain period in a conversation in the local database.

    throws

    A description of the exception. See ChatError.

    Parameters

    • startTime: number

      The starting Unix timestamp for search. The unit is millisecond.

    • endTime: number

      The ending Unix timestamp for search. The unit is millisecond.

    • direction: ChatSearchDirection = ChatSearchDirection.UP

      The message search direction. See ChatSearchDirection.

    • count: number = 20

      The maximum number of messages to retrieve each time. The value range is [1,400].

    Returns Promise<ChatMessage[]>

    The list of retrieved messages (excluding the ones with the starting or ending timestamp). If no message is obtained, an empty list is returned.

  • Retrieves messages of a certain quantity in a conversation from the local database.

    Note

    The obtained messages will also join the existing messages of the conversation stored in the memory.

    throws

    A description of the exception. See ChatError.

    Parameters

    • startMsgId: string

      The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set an empty string, the SDK retrieves messages according to the message search direction while ignoring this parameter. - If direction is set as ChatSearchDirection.UP, the SDK retrieves messages, starting from the latest one, in the descending order of the Unix timestamp (ChatOptions.sortMessageByServerTime) included in them. - If direction is set as ChatSearchDirection.DOWN, the SDK retrieves messages, starting from the oldest one, in the ascending order of the Unix timestamp (ChatOptions.sortMessageByServerTime) included in them.

    • direction: ChatSearchDirection = ChatSearchDirection.UP

      The message search direction. See ChatSearchDirection.

    • loadCount: number = 20

      The maximum number of messages to retrieve each time. The value range is [1,400].

    Returns Promise<ChatMessage[]>

    The message list (excluding the ones with the starting or ending timestamp). If no message is obtained, an empty list is returned.

  • getMessagesWithKeyword(keywords: string, direction?: ChatSearchDirection, timestamp?: number, count?: number, sender?: string): Promise<ChatMessage[]>
  • Retrieves messages with keywords in a conversation in the local database.

    throws

    A description of the exception. See ChatError.

    Parameters

    • keywords: string

      The keywords for query.

    • direction: ChatSearchDirection = ChatSearchDirection.UP

      The message search direction. See ChatSearchDirection.

    • timestamp: number = -1

      The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the the Unix timestamp (ChatOptions.sortMessageByServerTime) included in them.

    • count: number = 20

      The maximum number of messages to retrieve each time. The value range is [1,400].

    • Optional sender: string

      The user ID or group ID for retrieval. Usually, it is the conversation ID.

    Returns Promise<ChatMessage[]>

    The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned.

  • Retrieves messages of a certain type that a specified user sends in a conversation.

    throws

    A description of the exception. See ChatError.

    Parameters

    • msgType: ChatMessageType

      The message type. See ChatMessageType.

    • direction: ChatSearchDirection = ChatSearchDirection.UP

      The message search direction. See ChatSearchDirection.

    • timestamp: number = -1

      The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them.

    • count: number = 20

      The maximum number of messages to retrieve each time. The value range is [1,400].

    • Optional sender: string

      The user ID or group ID for retrieval. Usually, it is the conversation ID.

    Returns Promise<ChatMessage[]>

    The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned.

  • getUnreadCount(): Promise<number>
  • Gets the count of unread messages in the conversation.

    throws

    A description of the exception. See ChatError.

    Returns Promise<number>

    The count of unread messages.

  • markAllMessagesAsRead(): Promise<void>
  • Marks all messages as read.

    throws

    A description of the exception. See ChatError.

    Returns Promise<void>

  • markMessageAsRead(msgId: string): Promise<void>
  • Marks a message as read.

    throws

    A description of the exception. See ChatError.

    Parameters

    • msgId: string

      The message ID.

    Returns Promise<void>

  • name(): Promise<undefined | string>
  • Gets the conversation ID.

    Returns Promise<undefined | string>

    The conversation ID.

  • removeMessagesFromServerWithMsgIds(msgIds: string[]): Promise<void>
  • Deletes messages from the conversation (from both local storage and server).

    throws

    A description of the exception. See ChatError.

    Parameters

    • msgIds: string[]

      The IDs of messages to delete from the current conversation.

    Returns Promise<void>

  • removeMessagesFromServerWithTimestamp(timestamp: number): Promise<void>
  • Deletes messages from the conversation (from both local storage and server).

    throws

    A description of the exception. See ChatError.

    Parameters

    • timestamp: number

      The message timestamp in millisecond. The messages with the timestamp smaller than the specified one will be deleted.

    Returns Promise<void>

  • setConversationExtension(ext: {}): Promise<void>
  • Sets the extension information of the conversation.

    throws

    A description of the exception. See ChatError.

    Parameters

    • ext: {}

      The extension information of the conversation. This parameter must be in the key-value format.

      • [key: string]: string | number

    Returns Promise<void>

  • Updates a message in the local database.

    After you modify a message, the message ID remains unchanged and the SDK automatically updates attributes of the conversation, like latestMessage.

    throws

    A description of the exception. See ChatError.

    Parameters

    Returns Promise<void>

Generated using TypeDoc