ChatClient class
要執行聊天作業的用戶端
建構函式
Chat |
為指定的資源和使用者建立 ChatClient 的實例。 |
方法
建構函式詳細資料
ChatClient(string, CommunicationTokenCredential, ChatClientOptions)
為指定的資源和使用者建立 ChatClient 的實例。
new ChatClient(endpoint: string, credential: CommunicationTokenCredential, options?: ChatClientOptions)
參數
- endpoint
-
string
通訊服務資源的 URL。
- credential
- CommunicationTokenCredential
權杖認證。 使用 AzureCommunicationTokenCredential 從 @azure/communication-common 建立認證。
- options
- ChatClientOptions
其他用戶端選項。
方法詳細資料
createChatThread(CreateChatThreadRequest, CreateChatThreadOptions)
建立聊天對話。 傳回具有所建立執行緒識別碼的執行緒用戶端。
function createChatThread(request: CreateChatThreadRequest, options?: CreateChatThreadOptions): Promise<CreateChatThreadResult>
參數
- request
- CreateChatThreadRequest
建立聊天對話的要求。
- options
- CreateChatThreadOptions
作業選項。
傳回
Promise<CreateChatThreadResult>
deleteChatThread(string, OperationOptions)
刪除聊天對話。
function deleteChatThread(threadId: string, options?: OperationOptions): Promise<void>
參數
- threadId
-
string
要刪除之執行緒的識別碼。
- options
- OperationOptions
作業選項。
傳回
Promise<void>
getChatThreadClient(string)
傳回具有特定執行緒識別碼的 ChatThreadClient。
function getChatThreadClient(threadId: string): ChatThreadClient
參數
- threadId
-
string
ChatThreadClient 的執行緒識別碼
傳回
listChatThreads(RestListChatThreadsOptions)
取得使用者的聊天對話清單。
function listChatThreads(options?: RestListChatThreadsOptions): PagedAsyncIterableIterator<ChatThreadItem, ChatThreadItem[], PageSettings>
參數
- options
- RestListChatThreadsOptions
列出聊天對話選項。
傳回
off("chatMessageDeleted", (e: ChatMessageDeletedEvent) => void)
取消訂閱 chatMessageDeleted。
function off(event: "chatMessageDeleted", listener: (e: ChatMessageDeletedEvent) => void)
參數
- event
-
"chatMessageDeleted"
ChatMessageDeletedEvent。
- listener
-
(e: ChatMessageDeletedEvent) => void
要處理事件的接聽程式。
off("chatMessageEdited", (e: ChatMessageEditedEvent) => void)
取消訂閱 chatMessageEdited。
function off(event: "chatMessageEdited", listener: (e: ChatMessageEditedEvent) => void)
參數
- event
-
"chatMessageEdited"
ChatMessageEditedEvent。
- listener
-
(e: ChatMessageEditedEvent) => void
要處理事件的接聽程式。
off("chatMessageReceived", (e: ChatMessageReceivedEvent) => void)
取消訂閱 chatMessageReceived。
function off(event: "chatMessageReceived", listener: (e: ChatMessageReceivedEvent) => void)
參數
- event
-
"chatMessageReceived"
ChatMessageReceivedEvent。
- listener
-
(e: ChatMessageReceivedEvent) => void
要處理事件的接聽程式。
off("chatThreadCreated", (e: ChatThreadCreatedEvent) => void)
取消訂閱 chatThreadCreated。
function off(event: "chatThreadCreated", listener: (e: ChatThreadCreatedEvent) => void)
參數
- event
-
"chatThreadCreated"
ChatThreadCreatedEvent。
- listener
-
(e: ChatThreadCreatedEvent) => void
要處理事件的接聽程式。
off("chatThreadDeleted", (e: ChatThreadDeletedEvent) => void)
取消訂閱 chatThreadDeleted。
function off(event: "chatThreadDeleted", listener: (e: ChatThreadDeletedEvent) => void)
參數
- event
-
"chatThreadDeleted"
ChatThreadDeletedEvent。
- listener
-
(e: ChatThreadDeletedEvent) => void
要處理事件的接聽程式。
off("chatThreadPropertiesUpdated", (e: ChatThreadPropertiesUpdatedEvent) => void)
取消訂閱 chatThreadPropertiesUpdated。
function off(event: "chatThreadPropertiesUpdated", listener: (e: ChatThreadPropertiesUpdatedEvent) => void)
參數
- event
-
"chatThreadPropertiesUpdated"
ChatThreadPropertiesUpdatedEvent。
- listener
-
(e: ChatThreadPropertiesUpdatedEvent) => void
要處理事件的接聽程式。
off("participantsAdded", (e: ParticipantsAddedEvent) => void)
取消訂閱參與者新增。
function off(event: "participantsAdded", listener: (e: ParticipantsAddedEvent) => void)
參數
- event
-
"participantsAdded"
ParticipantsAddedEvent。
- listener
-
(e: ParticipantsAddedEvent) => void
要處理事件的接聽程式。
off("participantsRemoved", (e: ParticipantsRemovedEvent) => void)
取消訂閱參與者Removed。
function off(event: "participantsRemoved", listener: (e: ParticipantsRemovedEvent) => void)
參數
- event
-
"participantsRemoved"
ParticipantsRemovedEvent。
- listener
-
(e: ParticipantsRemovedEvent) => void
要處理事件的接聽程式。
off("readReceiptReceived", (e: ReadReceiptReceivedEvent) => void)
取消訂閱 readReceiptReceived。
function off(event: "readReceiptReceived", listener: (e: ReadReceiptReceivedEvent) => void)
參數
- event
-
"readReceiptReceived"
ReadReceiptReceivedEvent。
- listener
-
(e: ReadReceiptReceivedEvent) => void
要處理事件的接聽程式。
off("typingIndicatorReceived", (e: TypingIndicatorReceivedEvent) => void)
取消訂閱輸入IndicatorReceived。
function off(event: "typingIndicatorReceived", listener: (e: TypingIndicatorReceivedEvent) => void)
參數
- event
-
"typingIndicatorReceived"
TypingIndicatorReceivedEvent。
- listener
-
(e: TypingIndicatorReceivedEvent) => void
要處理事件的接聽程式。
on("chatMessageDeleted", (e: ChatMessageDeletedEvent) => void)
chatMessageDeleted 的訂閱函式。 初始傳送者也會收到此事件。
function on(event: "chatMessageDeleted", listener: (e: ChatMessageDeletedEvent) => void)
參數
- event
-
"chatMessageDeleted"
ChatMessageDeletedEvent。
- listener
-
(e: ChatMessageDeletedEvent) => void
要處理事件的接聽程式。
on("chatMessageEdited", (e: ChatMessageEditedEvent) => void)
chatMessageEdited 的訂閱函式。 初始傳送者也會收到此事件。
function on(event: "chatMessageEdited", listener: (e: ChatMessageEditedEvent) => void)
參數
- event
-
"chatMessageEdited"
ChatMessageEditedEvent。
- listener
-
(e: ChatMessageEditedEvent) => void
要處理事件的接聽程式。
on("chatMessageReceived", (e: ChatMessageReceivedEvent) => void)
chatMessageReceived 的訂閱函式。 初始傳送者也會收到此事件。 您必須在訂閱任何事件之前呼叫 startRealtimeNotifications。
function on(event: "chatMessageReceived", listener: (e: ChatMessageReceivedEvent) => void)
參數
- event
-
"chatMessageReceived"
ChatMessageReceivedEvent。
- listener
-
(e: ChatMessageReceivedEvent) => void
要處理事件的接聽程式。
on("chatThreadCreated", (e: ChatThreadCreatedEvent) => void)
chatThreadCreated 的訂閱函式。
function on(event: "chatThreadCreated", listener: (e: ChatThreadCreatedEvent) => void)
參數
- event
-
"chatThreadCreated"
ChatThreadCreatedEvent。
- listener
-
(e: ChatThreadCreatedEvent) => void
要處理事件的接聽程式。
on("chatThreadDeleted", (e: ChatThreadDeletedEvent) => void)
chatThreadDeleted 的訂閱函式。
function on(event: "chatThreadDeleted", listener: (e: ChatThreadDeletedEvent) => void)
參數
- event
-
"chatThreadDeleted"
ChatThreadDeletedEvent。
- listener
-
(e: ChatThreadDeletedEvent) => void
要處理事件的接聽程式。
on("chatThreadPropertiesUpdated", (e: ChatThreadPropertiesUpdatedEvent) => void)
chatThreadPropertiesUpdated 的 Subscribe 函式。
function on(event: "chatThreadPropertiesUpdated", listener: (e: ChatThreadPropertiesUpdatedEvent) => void)
參數
- event
-
"chatThreadPropertiesUpdated"
ChatThreadPropertiesUpdatedEvent。
- listener
-
(e: ChatThreadPropertiesUpdatedEvent) => void
要處理事件的接聽程式。
on("participantsAdded", (e: ParticipantsAddedEvent) => void)
訂閱參與者的函式Added。
function on(event: "participantsAdded", listener: (e: ParticipantsAddedEvent) => void)
參數
- event
-
"participantsAdded"
ParticipantsAddedEvent。
- listener
-
(e: ParticipantsAddedEvent) => void
要處理事件的接聽程式。
on("participantsRemoved", (e: ParticipantsRemovedEvent) => void)
針對參與者訂閱函式Removed。
function on(event: "participantsRemoved", listener: (e: ParticipantsRemovedEvent) => void)
參數
- event
-
"participantsRemoved"
ParticipantsRemovedEvent。
- listener
-
(e: ParticipantsRemovedEvent) => void
要處理事件的接聽程式。
on("readReceiptReceived", (e: ReadReceiptReceivedEvent) => void)
readReceiptReceived 的 Subscribe 函式。
function on(event: "readReceiptReceived", listener: (e: ReadReceiptReceivedEvent) => void)
參數
- event
-
"readReceiptReceived"
ReadReceiptReceivedEvent。
- listener
-
(e: ReadReceiptReceivedEvent) => void
要處理事件的接聽程式。
on("realTimeNotificationConnected", () => void)
realTimeNotificationConnected 的 Subscribe 函式。
function on(event: "realTimeNotificationConnected", listener: () => void)
參數
- event
-
"realTimeNotificationConnected"
realTimeNotificationConnected 事件
- listener
-
() => void
要處理事件的接聽程式。
on("realTimeNotificationDisconnected", () => void)
realTimeNotificationDisconnected 的 Subscribe 函式。
function on(event: "realTimeNotificationDisconnected", listener: () => void)
參數
- event
-
"realTimeNotificationDisconnected"
realTimeNotificationDisconnected 事件
- listener
-
() => void
要處理事件的接聽程式。
on("typingIndicatorReceived", (e: TypingIndicatorReceivedEvent) => void)
Subscribe 函式,用於 typingIndicatorReceived。 初始傳送者也會收到此事件。
function on(event: "typingIndicatorReceived", listener: (e: TypingIndicatorReceivedEvent) => void)
參數
- event
-
"typingIndicatorReceived"
TypingIndicatorReceivedEvent。
- listener
-
(e: TypingIndicatorReceivedEvent) => void
要處理事件的接聽程式。
startRealtimeNotifications()
開始接收即時通知。 訂閱任何事件之前,請先呼叫此函式。
function startRealtimeNotifications(): Promise<void>
傳回
Promise<void>
stopRealtimeNotifications()
停止接收即時通知。 此函式會取消訂閱所有事件。
function stopRealtimeNotifications(): Promise<void>
傳回
Promise<void>