StatefulChatClient interface

Defines the methods that allow {@Link @azure/communication-chat#ChatClient} to be used with a centralized generated state.

The interface provides access to proxied state and also allows registering a handler for state change events.

Extends

Methods

getState()

Holds all the state that we could proxy from ChatClient {@Link @azure/communication-chat#ChatClient} as ChatClientState {@Link ChatClientState}.

offStateChange((state: ChatClientState) => void)

Allows unregistering for 'stateChanged' events.

onStateChange((state: ChatClientState) => void)

Allows a handler to be registered for 'stateChanged' events.

Inherited Methods

createChatThread(CreateChatThreadRequest, CreateChatThreadOptions)

Creates a chat thread. Returns thread client with the id of the created thread.

deleteChatThread(string, OperationOptions)

Deletes a chat thread.

getChatThreadClient(string)

Returns ChatThreadClient with the specific thread id.

listChatThreads(RestListChatThreadsOptions)

Gets the list of chat threads of a user.

off("chatMessageDeleted", (e: ChatMessageDeletedEvent) => void)

Unsubscribe from chatMessageDeleted.

off("chatMessageEdited", (e: ChatMessageEditedEvent) => void)

Unsubscribe from chatMessageEdited.

off("chatMessageReceived", (e: ChatMessageReceivedEvent) => void)

Unsubscribe from chatMessageReceived.

off("chatThreadCreated", (e: ChatThreadCreatedEvent) => void)

Unsubscribe from chatThreadCreated.

off("chatThreadDeleted", (e: ChatThreadDeletedEvent) => void)

Unsubscribe from chatThreadDeleted.

off("chatThreadPropertiesUpdated", (e: ChatThreadPropertiesUpdatedEvent) => void)

Unsubscribe from chatThreadPropertiesUpdated.

off("participantsAdded", (e: ParticipantsAddedEvent) => void)

Unsubscribe from participantsAdded.

off("participantsRemoved", (e: ParticipantsRemovedEvent) => void)

Unsubscribe from participantsRemoved.

off("readReceiptReceived", (e: ReadReceiptReceivedEvent) => void)

Unsubscribe from readReceiptReceived.

off("typingIndicatorReceived", (e: TypingIndicatorReceivedEvent) => void)

Unsubscribe from typingIndicatorReceived.

on("chatMessageDeleted", (e: ChatMessageDeletedEvent) => void)

Subscribe function for chatMessageDeleted. The initial sender will also receive this event.

on("chatMessageEdited", (e: ChatMessageEditedEvent) => void)

Subscribe function for chatMessageEdited. The initial sender will also receive this event.

on("chatMessageReceived", (e: ChatMessageReceivedEvent) => void)

Subscribe function for chatMessageReceived. The initial sender will also receive this event. You need to call startRealtimeNotifications before subscribing to any event.

on("chatThreadCreated", (e: ChatThreadCreatedEvent) => void)

Subscribe function for chatThreadCreated.

on("chatThreadDeleted", (e: ChatThreadDeletedEvent) => void)

Subscribe function for chatThreadDeleted.

on("chatThreadPropertiesUpdated", (e: ChatThreadPropertiesUpdatedEvent) => void)

Subscribe function for chatThreadPropertiesUpdated.

on("participantsAdded", (e: ParticipantsAddedEvent) => void)

Subscribe function for participantsAdded.

on("participantsRemoved", (e: ParticipantsRemovedEvent) => void)

Subscribe function for participantsRemoved.

on("readReceiptReceived", (e: ReadReceiptReceivedEvent) => void)

Subscribe function for readReceiptReceived.

on("realTimeNotificationConnected", () => void)

Subscribe function for realTimeNotificationConnected.

on("realTimeNotificationDisconnected", () => void)

Subscribe function for realTimeNotificationDisconnected.

on("typingIndicatorReceived", (e: TypingIndicatorReceivedEvent) => void)

Subscribe function for typingIndicatorReceived. The initial sender will also receive this event.

startRealtimeNotifications()

Start receiving realtime notifications. Call this function before subscribing to any event.

stopRealtimeNotifications()

Stop receiving realtime notifications. This function would unsubscribe to all events.

Method Details

getState()

Holds all the state that we could proxy from ChatClient {@Link @azure/communication-chat#ChatClient} as ChatClientState {@Link ChatClientState}.

function getState(): ChatClientState

Returns

offStateChange((state: ChatClientState) => void)

Allows unregistering for 'stateChanged' events.

function offStateChange(handler: (state: ChatClientState) => void)

Parameters

handler

(state: ChatClientState) => void

Original callback to be unsubscribed.

onStateChange((state: ChatClientState) => void)

Allows a handler to be registered for 'stateChanged' events.

function onStateChange(handler: (state: ChatClientState) => void)

Parameters

handler

(state: ChatClientState) => void

Callback to receive the state.

Inherited Method Details

createChatThread(CreateChatThreadRequest, CreateChatThreadOptions)

Creates a chat thread. Returns thread client with the id of the created thread.

function createChatThread(request: CreateChatThreadRequest, options?: CreateChatThreadOptions): Promise<CreateChatThreadResult>

Parameters

request
CreateChatThreadRequest

Request for creating a chat thread.

options
CreateChatThreadOptions

Operation options.

Returns

Inherited From ChatClient.createChatThread

deleteChatThread(string, OperationOptions)

Deletes a chat thread.

function deleteChatThread(threadId: string, options?: OperationOptions): Promise<void>

Parameters

threadId

string

The ID of the thread to delete.

options
OperationOptions

Operation options.

Returns

Promise<void>

Inherited From ChatClient.deleteChatThread

getChatThreadClient(string)

Returns ChatThreadClient with the specific thread id.

function getChatThreadClient(threadId: string): ChatThreadClient

Parameters

threadId

string

Thread ID for the ChatThreadClient

Returns

Inherited From ChatClient.getChatThreadClient

listChatThreads(RestListChatThreadsOptions)

Gets the list of chat threads of a user.

function listChatThreads(options?: RestListChatThreadsOptions): PagedAsyncIterableIterator<ChatThreadItem, ChatThreadItem[], PageSettings>

Parameters

options
RestListChatThreadsOptions

List chat threads options.

Returns

Inherited From ChatClient.listChatThreads

off("chatMessageDeleted", (e: ChatMessageDeletedEvent) => void)

Unsubscribe from chatMessageDeleted.

function off(event: "chatMessageDeleted", listener: (e: ChatMessageDeletedEvent) => void)

Parameters

event

"chatMessageDeleted"

The ChatMessageDeletedEvent.

listener

(e: ChatMessageDeletedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("chatMessageEdited", (e: ChatMessageEditedEvent) => void)

Unsubscribe from chatMessageEdited.

function off(event: "chatMessageEdited", listener: (e: ChatMessageEditedEvent) => void)

Parameters

event

"chatMessageEdited"

The ChatMessageEditedEvent.

listener

(e: ChatMessageEditedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("chatMessageReceived", (e: ChatMessageReceivedEvent) => void)

Unsubscribe from chatMessageReceived.

function off(event: "chatMessageReceived", listener: (e: ChatMessageReceivedEvent) => void)

Parameters

event

"chatMessageReceived"

The ChatMessageReceivedEvent.

listener

(e: ChatMessageReceivedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("chatThreadCreated", (e: ChatThreadCreatedEvent) => void)

Unsubscribe from chatThreadCreated.

function off(event: "chatThreadCreated", listener: (e: ChatThreadCreatedEvent) => void)

Parameters

event

"chatThreadCreated"

The ChatThreadCreatedEvent.

listener

(e: ChatThreadCreatedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("chatThreadDeleted", (e: ChatThreadDeletedEvent) => void)

Unsubscribe from chatThreadDeleted.

function off(event: "chatThreadDeleted", listener: (e: ChatThreadDeletedEvent) => void)

Parameters

event

"chatThreadDeleted"

The ChatThreadDeletedEvent.

listener

(e: ChatThreadDeletedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("chatThreadPropertiesUpdated", (e: ChatThreadPropertiesUpdatedEvent) => void)

Unsubscribe from chatThreadPropertiesUpdated.

function off(event: "chatThreadPropertiesUpdated", listener: (e: ChatThreadPropertiesUpdatedEvent) => void)

Parameters

event

"chatThreadPropertiesUpdated"

The ChatThreadPropertiesUpdatedEvent.

listener

(e: ChatThreadPropertiesUpdatedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("participantsAdded", (e: ParticipantsAddedEvent) => void)

Unsubscribe from participantsAdded.

function off(event: "participantsAdded", listener: (e: ParticipantsAddedEvent) => void)

Parameters

event

"participantsAdded"

The ParticipantsAddedEvent.

listener

(e: ParticipantsAddedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("participantsRemoved", (e: ParticipantsRemovedEvent) => void)

Unsubscribe from participantsRemoved.

function off(event: "participantsRemoved", listener: (e: ParticipantsRemovedEvent) => void)

Parameters

event

"participantsRemoved"

The ParticipantsRemovedEvent.

listener

(e: ParticipantsRemovedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("readReceiptReceived", (e: ReadReceiptReceivedEvent) => void)

Unsubscribe from readReceiptReceived.

function off(event: "readReceiptReceived", listener: (e: ReadReceiptReceivedEvent) => void)

Parameters

event

"readReceiptReceived"

The ReadReceiptReceivedEvent.

listener

(e: ReadReceiptReceivedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

off("typingIndicatorReceived", (e: TypingIndicatorReceivedEvent) => void)

Unsubscribe from typingIndicatorReceived.

function off(event: "typingIndicatorReceived", listener: (e: TypingIndicatorReceivedEvent) => void)

Parameters

event

"typingIndicatorReceived"

The TypingIndicatorReceivedEvent.

listener

(e: TypingIndicatorReceivedEvent) => void

The listener to handle the event.

Inherited From ChatClient.off

on("chatMessageDeleted", (e: ChatMessageDeletedEvent) => void)

Subscribe function for chatMessageDeleted. The initial sender will also receive this event.

function on(event: "chatMessageDeleted", listener: (e: ChatMessageDeletedEvent) => void)

Parameters

event

"chatMessageDeleted"

The ChatMessageDeletedEvent.

listener

(e: ChatMessageDeletedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("chatMessageEdited", (e: ChatMessageEditedEvent) => void)

Subscribe function for chatMessageEdited. The initial sender will also receive this event.

function on(event: "chatMessageEdited", listener: (e: ChatMessageEditedEvent) => void)

Parameters

event

"chatMessageEdited"

The ChatMessageEditedEvent.

listener

(e: ChatMessageEditedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("chatMessageReceived", (e: ChatMessageReceivedEvent) => void)

Subscribe function for chatMessageReceived. The initial sender will also receive this event. You need to call startRealtimeNotifications before subscribing to any event.

function on(event: "chatMessageReceived", listener: (e: ChatMessageReceivedEvent) => void)

Parameters

event

"chatMessageReceived"

The ChatMessageReceivedEvent.

listener

(e: ChatMessageReceivedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("chatThreadCreated", (e: ChatThreadCreatedEvent) => void)

Subscribe function for chatThreadCreated.

function on(event: "chatThreadCreated", listener: (e: ChatThreadCreatedEvent) => void)

Parameters

event

"chatThreadCreated"

The ChatThreadCreatedEvent.

listener

(e: ChatThreadCreatedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("chatThreadDeleted", (e: ChatThreadDeletedEvent) => void)

Subscribe function for chatThreadDeleted.

function on(event: "chatThreadDeleted", listener: (e: ChatThreadDeletedEvent) => void)

Parameters

event

"chatThreadDeleted"

The ChatThreadDeletedEvent.

listener

(e: ChatThreadDeletedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("chatThreadPropertiesUpdated", (e: ChatThreadPropertiesUpdatedEvent) => void)

Subscribe function for chatThreadPropertiesUpdated.

function on(event: "chatThreadPropertiesUpdated", listener: (e: ChatThreadPropertiesUpdatedEvent) => void)

Parameters

event

"chatThreadPropertiesUpdated"

The ChatThreadPropertiesUpdatedEvent.

listener

(e: ChatThreadPropertiesUpdatedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("participantsAdded", (e: ParticipantsAddedEvent) => void)

Subscribe function for participantsAdded.

function on(event: "participantsAdded", listener: (e: ParticipantsAddedEvent) => void)

Parameters

event

"participantsAdded"

The ParticipantsAddedEvent.

listener

(e: ParticipantsAddedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("participantsRemoved", (e: ParticipantsRemovedEvent) => void)

Subscribe function for participantsRemoved.

function on(event: "participantsRemoved", listener: (e: ParticipantsRemovedEvent) => void)

Parameters

event

"participantsRemoved"

The ParticipantsRemovedEvent.

listener

(e: ParticipantsRemovedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("readReceiptReceived", (e: ReadReceiptReceivedEvent) => void)

Subscribe function for readReceiptReceived.

function on(event: "readReceiptReceived", listener: (e: ReadReceiptReceivedEvent) => void)

Parameters

event

"readReceiptReceived"

The ReadReceiptReceivedEvent.

listener

(e: ReadReceiptReceivedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

on("realTimeNotificationConnected", () => void)

Subscribe function for realTimeNotificationConnected.

function on(event: "realTimeNotificationConnected", listener: () => void)

Parameters

event

"realTimeNotificationConnected"

The realTimeNotificationConnected Event

listener

() => void

The listener to handle the event.

Inherited From ChatClient.on

on("realTimeNotificationDisconnected", () => void)

Subscribe function for realTimeNotificationDisconnected.

function on(event: "realTimeNotificationDisconnected", listener: () => void)

Parameters

event

"realTimeNotificationDisconnected"

The realTimeNotificationDisconnected Event

listener

() => void

The listener to handle the event.

Inherited From ChatClient.on

on("typingIndicatorReceived", (e: TypingIndicatorReceivedEvent) => void)

Subscribe function for typingIndicatorReceived. The initial sender will also receive this event.

function on(event: "typingIndicatorReceived", listener: (e: TypingIndicatorReceivedEvent) => void)

Parameters

event

"typingIndicatorReceived"

The TypingIndicatorReceivedEvent.

listener

(e: TypingIndicatorReceivedEvent) => void

The listener to handle the event.

Inherited From ChatClient.on

startRealtimeNotifications()

Start receiving realtime notifications. Call this function before subscribing to any event.

function startRealtimeNotifications(): Promise<void>

Returns

Promise<void>

Inherited From ChatClient.startRealtimeNotifications

stopRealtimeNotifications()

Stop receiving realtime notifications. This function would unsubscribe to all events.

function stopRealtimeNotifications(): Promise<void>

Returns

Promise<void>

Inherited From ChatClient.stopRealtimeNotifications