Package com.azure.communication.chat
Class ChatThreadAsyncClient
java.lang.Object
com.azure.communication.chat.ChatThreadAsyncClient
Async Client that supports chat thread operations.
Instantiating an asynchronous Chat Thread Client
// Initialize the chat client builder final ChatClientBuilder builder = new ChatClientBuilder() .endpoint(endpoint) .credential(credential); // Build the chat client ChatAsyncClient chatClient = builder.buildAsyncClient(); // Get the chat thread client for your thread's id ChatThreadAsyncClient chatThreadClient = chatClient.getChatThreadClient(threadId);
View this
for additional ways to construct the client.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddParticipant
(ChatParticipant participant) Adds a participant to a thread.addParticipants
(Iterable<ChatParticipant> participants) Adds participants to a thread.addParticipantsWithResponse
(Iterable<ChatParticipant> participants) Adds participants to a thread.addParticipantWithResponse
(ChatParticipant participant) Adds a participant to a thread.deleteMessage
(String chatMessageId) Deletes a message.deleteMessageWithResponse
(String chatMessageId) Deletes a message.Get the thread id property.getMessage
(String chatMessageId) Gets a message by id.getMessageWithResponse
(String chatMessageId) Gets a message by id.Gets chat thread properties.Gets chat thread properties.Gets a list of messages from a thread.listMessages
(ListChatMessagesOptions listMessagesOptions) Gets a list of messages from a thread.Gets the participants of a thread.listParticipants
(ListParticipantsOptions listParticipantsOptions) Gets the participants of a thread.Gets read receipts for a thread.listReadReceipts
(ListReadReceiptOptions listReadReceiptOptions) Gets read receipts for a thread.removeParticipant
(CommunicationIdentifier identifier) Remove a participant from a thread.removeParticipantWithResponse
(CommunicationIdentifier identifier) Remove a participant from a thread.sendMessage
(SendChatMessageOptions options) Sends a message to a thread.Sends a message to a thread.sendReadReceipt
(String chatMessageId) Posts a read receipt event to a thread, on behalf of a user.sendReadReceiptWithResponse
(String chatMessageId) Posts a read receipt event to a thread, on behalf of a user.Posts a typing event to a thread, on behalf of a user.Posts a typing event to a thread, on behalf of a user.Posts a typing event to a thread, on behalf of a user.updateMessage
(String chatMessageId, UpdateChatMessageOptions options) Updates a message.updateMessageWithResponse
(String chatMessageId, UpdateChatMessageOptions options) Updates a message.updateTopic
(String topic) Updates a thread's topic.updateTopicWithResponse
(String topic) Updates a thread's properties.
-
Method Details
-
getChatThreadId
Get the thread id property.- Returns:
- the thread id value.
-
updateTopic
Updates a thread's topic.- Parameters:
topic
- The new topic.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
updateTopicWithResponse
Updates a thread's properties.- Parameters:
topic
- The new topic.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
addParticipants
Adds participants to a thread. If participants already exist, no change occurs.- Parameters:
participants
- Collection of participants to add.- Returns:
- the result.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
addParticipantsWithResponse
public Mono<Response<AddChatParticipantsResult>> addParticipantsWithResponse(Iterable<ChatParticipant> participants) Adds participants to a thread. If participants already exist, no change occurs.- Parameters:
participants
- Collection of participants to add.- Returns:
- the result.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
addParticipant
Adds a participant to a thread. If the participant already exists, no change occurs.- Parameters:
participant
- The new participant.- Returns:
- nothing.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.InvalidParticipantException
- thrown if the participant is rejected by the server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
addParticipantWithResponse
Adds a participant to a thread. If the participant already exists, no change occurs.- Parameters:
participant
- The new participant.- Returns:
- the response.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.InvalidParticipantException
- thrown if the participant is rejected by the server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
removeParticipant
Remove a participant from a thread.- Parameters:
identifier
- Identity of the participant to remove from the thread.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
removeParticipantWithResponse
Remove a participant from a thread.- Parameters:
identifier
- Identity of the participant to remove from the thread.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
listParticipants
Gets the participants of a thread.- Returns:
- the participants of a thread.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
listParticipants
Gets the participants of a thread.- Parameters:
listParticipantsOptions
- The request options.- Returns:
- the participants of a thread.
-
sendMessage
Sends a message to a thread.Code Samples
Send a chat message based on "options".
// Set the chat message options SendChatMessageOptions sendChatMessageOptions = new SendChatMessageOptions() .setContent("Message content") .setSenderDisplayName("Sender Display Name"); // Get the request result and the chat message id SendChatMessageResult sendResult = chatThreadClient.sendMessage(sendChatMessageOptions).block(); String messageId = sendResult.getId();
- Parameters:
options
- Options for sending the message.- Returns:
- the SendChatMessageResult.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendMessageWithResponse
public Mono<Response<SendChatMessageResult>> sendMessageWithResponse(SendChatMessageOptions options) Sends a message to a thread.- Parameters:
options
- Options for sending the message.- Returns:
- the SendChatMessageResult.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getMessage
Gets a message by id.- Parameters:
chatMessageId
- The message id.- Returns:
- a message by id.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getMessageWithResponse
Gets a message by id.- Parameters:
chatMessageId
- The message id.- Returns:
- a message by id.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
listMessages
Gets a list of messages from a thread.- Returns:
- a paged list of messages from a thread.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
listMessages
Gets a list of messages from a thread.- Parameters:
listMessagesOptions
- The request options.- Returns:
- a paged list of messages from a thread.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
updateMessage
Updates a message.- Parameters:
chatMessageId
- The message id.options
- Options for updating the message.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
updateMessageWithResponse
public Mono<Response<Void>> updateMessageWithResponse(String chatMessageId, UpdateChatMessageOptions options) Updates a message.- Parameters:
chatMessageId
- The message id.options
- Options for updating the message.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
deleteMessage
Deletes a message.- Parameters:
chatMessageId
- The message id.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
deleteMessageWithResponse
Deletes a message.- Parameters:
chatMessageId
- The message id.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendTypingNotification
Posts a typing event to a thread, on behalf of a user.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendTypingNotificationWithResponse
Posts a typing event to a thread, on behalf of a user.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendTypingNotificationWithResponse
Posts a typing event to a thread, on behalf of a user.- Parameters:
options
- Options for sending the typing notification.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendReadReceipt
Posts a read receipt event to a thread, on behalf of a user.- Parameters:
chatMessageId
- The id of the chat message that was read.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendReadReceiptWithResponse
Posts a read receipt event to a thread, on behalf of a user.- Parameters:
chatMessageId
- The id of the chat message that was read.- Returns:
- the completion.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
listReadReceipts
Gets read receipts for a thread.- Returns:
- read receipts for a thread.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
listReadReceipts
public PagedFlux<ChatMessageReadReceipt> listReadReceipts(ListReadReceiptOptions listReadReceiptOptions) Gets read receipts for a thread.- Parameters:
listReadReceiptOptions
- The additional options for this operation.- Returns:
- read receipts for a thread.
-
getProperties
Gets chat thread properties.- Returns:
- chat thread properties.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getPropertiesWithResponse
Gets chat thread properties.- Returns:
- chat thread properties.
- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-