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 changessubject
: 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 |
Removes the chat from the list of chats. |
|
public |
async cancelPendingMessage(message: ChatMessage): Promise<void> Cancels a pending file message. |
|
public |
Removes the group chat. |
|
public |
expelParticipant(participant: string): Promise Expels a participant from the chat. |
|
public |
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 |
getSubject(): string 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 |
Leaves the group chat. |
|
public |
async resetUnreadMessageCount(): Promise Resets the count of unread messages. |
|
public |
Sends a new file message. |
|
public |
Sends a new text message. |
|
public |
Changes the name of the chat. |
|
public |
setParticipantRole(participant: string, role: ChatParticipantRole): Promise Changes the role of a chat participant. |
|
public |
setState(state: ChatParticipantState): Promise Updates the state of the local participant in the chat. |
|
public |
async setSubject(subject: string): Promise Changes the subject of the chat group. |
|
public |
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 Methods
public async addParticipant(participant: string): Promise source
Adds a new participant to the chat.
Params:
Name | Type | Attribute | Description |
participant | string | The address of the user that wants to be added |
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.
public async cancelPendingMessage(message: ChatMessage): Promise<void> source
Cancels a pending file message. This is only applicable for file messages.
Params:
Name | Type | Attribute | Description |
message | ChatMessage | The chat message that wants to be cancelled. |
public async delete(): Promise source
Removes the group chat. Only group chats can be deleted and only admins can delete them.
public expelParticipant(participant: string): Promise source
Expels a participant from the chat.
Params:
Name | Type | Attribute | Description |
participant | string | The address of the user that will be expelled |
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:
Name | Type | Attribute | Description |
minimum | number |
|
The minimum number of messages that will be retrieved if available. |
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.
public getFirstUnreadMessage$(): Observable<ChatMessage> source
Returns an Observable of the first unread message or undefined if every message is already read.
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.
public getLastMessageTimestamp(): number source
Returns the timestamp of the last sent or received message including group invitations
public getName(): string source
Returns the name of the chat. This is only applicable for group chats.
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.
public getSubject(): string source
Returns the subject of the chat. This is only applicable for group chats
public getUnreadMessageCount$(): Observable<number> source
Returns an observable of the count of unread messages.
public isOldestMessageRecovered(): boolean source
Indicates if the oldest message of the chat has already been recovered.
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.
public async sendFile(file: File): Promise source
Sends a new file message.
Params:
Name | Type | Attribute | Description |
file | File | A file that wants to be sent to this chat |
public async sendText(text: string): Promise source
Sends a new text message.
Params:
Name | Type | Attribute | Description |
text | string | The text of the new message |
public async setName(name: string): Promise source
Changes the name of the chat. This is only applicable for group chats.
Params:
Name | Type | Attribute | Description |
name | string | The new name |
public setParticipantRole(participant: string, role: ChatParticipantRole): Promise source
Changes the role of a chat participant.
Params:
Name | Type | Attribute | Description |
participant | string | The address of the user whose role wants to be changed |
|
role | ChatParticipantRole | The new role of this participant |
public setState(state: ChatParticipantState): Promise source
Updates the state of the local participant in the chat.
Params:
Name | Type | Attribute | Description |
state | ChatParticipantState | the new state of the local particpant |