Home Reference Source
import {Chat} from '@quobis/sippojs'
public class | source

Chat

Provides access to methods for managing a chat room. See ChatManager to find how Chat objects are obtained

Events

  • name: Emitted every time the name changes
  • subject: Emitted every time the subject changes.
  • participants: Emitted every time the participants Map changes.
  • remoteParticipants: Emitted every time the remoteParticipants Map changes.
  • messages Emitted every time the messages List changes. (deprecated)
  • fileMessages Emitted every time a fileMessages List changes.
  • pendingMessages Emitted every time the pendingMessages List changes.
  • firstUnreadMessage Emitted every time the firstUnreadMessage changes. (deprecated)

Some events are deprecated because an observable is also provided. The use of the observable is encouraged and events will be removed at some time in the future.

Member Summary

Public Members
public

emitter: EventEmitter

public get

The the first unread message or undefined if every message is already read.

public get

The list of chat messages.

Method Summary

Public Methods
public

async addParticipant(participant: string): Promise

Adds a new participant to the chat.

public

async archive(): Promise

Removes the chat from the list of chats.

public

async cancelPendingMessage(message: ChatMessage): Promise<void>

Cancels a pending file message.

public

async delete(): Promise

Removes the group chat.

public

Expels a participant from the chat.

public

async fetch(minimum: number): Promise<void>

Recovers older messages of this chat.

public

Returns the list of chat messages with file type.

public

Returns the first unread message or undefined if every message is already read.

public

Returns an Observable of the first unread message or undefined if every message is already read.

public

The ID of this chat.

public

Returns the timestamp of the last sent or received message including group invitations

public

Returns the list of chat messages.

public

Returns the list of chat messages.

public

Returns the name of the chat.

public

Returns a Map with the role of each participant.

public

Returns the list of messages that have not been received by the server yet.

public

Returns a Map with the state of each remote participant.

public

Returns the role of the user in the chat.

public

Returns the subject of the chat.

public

Returns the type of the chat.

public

Returns the count of unread messages.

public

Returns an observable of the count of unread messages.

public

Indicates if the oldest message of the chat has already been recovered.

public

async leave(): Promise

Leaves the group chat.

public

Resets the count of unread messages.

public

async sendFile(file: File): Promise

Sends a new file message.

public

async sendText(text: string): Promise

Sends a new text message.

public

async setName(name: string): Promise

Changes the name of the chat.

public

Changes the role of a chat participant.

public

Updates the state of the local participant in the chat.

public

async setSubject(subject: string): Promise

Changes the subject of the chat group.

public

async sync(): Promise<void>

Retrieves messages since last message fetching (new messages)

Public Members

public emitter: EventEmitter source

public get firstUnreadMessage: ChatMessage source

The the first unread message or undefined if every message is already read.

public get messages: ImmutableList<ChatMessage> source

The list of chat messages.

Public Methods

public async addParticipant(participant: string): Promise source

Adds a new participant to the chat.

Params:

NameTypeAttributeDescription
participant string

The address of the user that wants to be added

Return:

Promise

public async archive(): Promise source

Removes the chat from the list of chats. Only individual chats can be archived. Group chats need to be leaved or deleted instead.

Return:

Promise

public async cancelPendingMessage(message: ChatMessage): Promise<void> source

Cancels a pending file message. This is only applicable for file messages.

Params:

NameTypeAttributeDescription
message ChatMessage

The chat message that wants to be cancelled.

Return:

Promise<void>

public async delete(): Promise source

Removes the group chat. Only group chats can be deleted and only admins can delete them.

Return:

Promise

public expelParticipant(participant: string): Promise source

Expels a participant from the chat.

Params:

NameTypeAttributeDescription
participant string

The address of the user that will be expelled

Return:

Promise

public async fetch(minimum: number): Promise<void> source

Recovers older messages of this chat. At least the number of messages specified is guaranteed to be recovered from the server if available. Only if the oldest message is reached a lower number of messages will be recovered. If that happens, it could be detected using Chat#isOldestMessageRecovered. Recovered messages will be included in the list of messages that is returned using Chat#getMessages. and are guaranteed to be accessible when the promise returned by this method is resolved.

Params:

NameTypeAttributeDescription
minimum number
  • optional
  • default: 10

The minimum number of messages that will be retrieved if available.

Return:

Promise<void>

public getFileMessages(): ImmutableList<ChatMessage> source

Returns the list of chat messages with file type.

public getFirstUnreadMessage(): ChatMessage source

Returns the first unread message or undefined if every message is already read.

Return:

ChatMessage

public getFirstUnreadMessage$(): Observable<ChatMessage> source

Returns an Observable of the first unread message or undefined if every message is already read.

Return:

Observable<ChatMessage>

public getId(): string source

The ID of this chat. The ID is only locally unique as it is derived from the remote participant in the case of individual chats and from the room address for group chats.

Return:

string

Unique identifier of the chat

public getLastMessageTimestamp(): number source

Returns the timestamp of the last sent or received message including group invitations

Return:

number

public getMessages(): ImmutableList<ChatMessage> source

Returns the list of chat messages.

public getMessages$(): ImmutableList<ChatMessage> source

Returns the list of chat messages.

public getName(): string source

Returns the name of the chat. This is only applicable for group chats.

Return:

string

Name of the chat

public getParticipants(): ImmutableMap<string, ChatParticipantRole> source

Returns a Map with the role of each participant.

public getPendingMessages(): ImmutableList<ChatMessage> source

Returns the list of messages that have not been received by the server yet.

public getRemoteParticipants(): ImmutableMap<string, ChatParticipantState> source

Returns a Map with the state of each remote participant.

public getRole(): ChatParticipantRole source

Returns the role of the user in the chat. This is only applicable for group chats.

Return:

ChatParticipantRole

The role of this user in the chat

public getSubject(): string source

Returns the subject of the chat. This is only applicable for group chats

Return:

string

Subject of the chat

public getType(): ChatType source

Returns the type of the chat.

Return:

ChatType

Type of the chat

public getUnreadMessageCount(): number source

Returns the count of unread messages.

Return:

number

public getUnreadMessageCount$(): Observable<number> source

Returns an observable of the count of unread messages.

Return:

Observable<number>

public isOldestMessageRecovered(): boolean source

Indicates if the oldest message of the chat has already been recovered.

Return:

boolean

public async leave(): Promise source

Leaves the group chat. Only group chats can be deleted and only members can leave them. Admins need to stop being an admin before.

Return:

Promise

public async resetUnreadMessageCount(): Promise source

Resets the count of unread messages.

Return:

Promise

public async sendFile(file: File): Promise source

Sends a new file message.

Params:

NameTypeAttributeDescription
file File

A file that wants to be sent to this chat

Return:

Promise

Resolved when the message is received by the server

public async sendText(text: string): Promise source

Sends a new text message.

Params:

NameTypeAttributeDescription
text string

The text of the new message

Return:

Promise

Resolved when the message is received by the server

public async setName(name: string): Promise source

Changes the name of the chat. This is only applicable for group chats.

Params:

NameTypeAttributeDescription
name string

The new name

Return:

Promise

public setParticipantRole(participant: string, role: ChatParticipantRole): Promise source

Changes the role of a chat participant.

Params:

NameTypeAttributeDescription
participant string

The address of the user whose role wants to be changed

role ChatParticipantRole

The new role of this participant

Return:

Promise

public setState(state: ChatParticipantState): Promise source

Updates the state of the local participant in the chat.

Params:

NameTypeAttributeDescription
state ChatParticipantState

the new state of the local particpant

Return:

Promise

public async setSubject(subject: string): Promise source

Changes the subject of the chat group. This is only applicable for group chats

Params:

NameTypeAttributeDescription
subject string

The new subject

Return:

Promise

public async sync(): Promise<void> source

Retrieves messages since last message fetching (new messages)

This is to catch up from the server's MAM

Return:

Promise<void>