Package com.azure.communication.chat
Class ChatThreadClient
java.lang.Object
com.azure.communication.chat.ChatThreadClient
Sync Client that supports chat thread operations.
Instantiating a synchronous Chat Thread Client
// Initialize the chat client builder final ChatClientBuilder builder = new ChatClientBuilder() .endpoint(endpoint) .credential(credential); // Build the chat client ChatClient chatClient = builder.buildClient(); // Get the chat thread client for your thread's id ChatThreadClient chatThreadClient = chatClient.getChatThreadClient(threadId);
View this
for additional ways to construct the client.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addParticipant
(ChatParticipant participant) Adds a participant to a thread.addParticipants
(Iterable<ChatParticipant> participants) Adds participants to a thread.com.azure.core.http.rest.Response
<AddChatParticipantsResult> addParticipantsWithResponse
(Iterable<ChatParticipant> participants, com.azure.core.util.Context context) Adds participants to a thread.com.azure.core.http.rest.Response
<Void> addParticipantWithResponse
(ChatParticipant participant, com.azure.core.util.Context context) Adds a participant to a thread.void
deleteMessage
(String chatMessageId) Deletes a message.com.azure.core.http.rest.Response
<Void> deleteMessageWithResponse
(String chatMessageId, com.azure.core.util.Context context) Deletes a message.Get the thread id property.getMessage
(String chatMessageId) Gets a message by id.com.azure.core.http.rest.Response
<ChatMessage> getMessageWithResponse
(String chatMessageId, com.azure.core.util.Context context) Gets a message by id.Gets chat thread properties.com.azure.core.http.rest.Response
<ChatThreadProperties> getPropertiesWithResponse
(com.azure.core.util.Context context) Gets chat thread properties.com.azure.core.http.rest.PagedIterable
<ChatMessage> Gets a list of messages from a thread.com.azure.core.http.rest.PagedIterable
<ChatMessage> listMessages
(ListChatMessagesOptions listMessagesOptions, com.azure.core.util.Context context) Gets a list of messages from a thread.com.azure.core.http.rest.PagedIterable
<ChatParticipant> Gets the participants of a thread.com.azure.core.http.rest.PagedIterable
<ChatParticipant> listParticipants
(ListParticipantsOptions listParticipantsOptions, com.azure.core.util.Context context) Gets the participants of a thread.com.azure.core.http.rest.PagedIterable
<ChatMessageReadReceipt> Gets read receipts for a thread.com.azure.core.http.rest.PagedIterable
<ChatMessageReadReceipt> listReadReceipts
(ListReadReceiptOptions listReadReceiptOptions, com.azure.core.util.Context context) Gets read receipts for a thread.void
removeParticipant
(CommunicationIdentifier identifier) Remove a participant from a thread.com.azure.core.http.rest.Response
<Void> removeParticipantWithResponse
(CommunicationIdentifier identifier, com.azure.core.util.Context context) Remove a participant from a thread.sendMessage
(SendChatMessageOptions options) Sends a message to a thread.com.azure.core.http.rest.Response
<SendChatMessageResult> sendMessageWithResponse
(SendChatMessageOptions options, com.azure.core.util.Context context) Sends a message to a thread.void
sendReadReceipt
(String chatMessageId) Posts a read receipt event to a thread, on behalf of a user.com.azure.core.http.rest.Response
<Void> sendReadReceiptWithResponse
(String chatMessageId, com.azure.core.util.Context context) Posts a read receipt event to a thread, on behalf of a user.void
Posts a typing event to a thread, on behalf of a user.com.azure.core.http.rest.Response
<Void> sendTypingNotificationWithResponse
(TypingNotificationOptions options, com.azure.core.util.Context context) Posts a typing event to a thread, on behalf of a user.com.azure.core.http.rest.Response
<Void> sendTypingNotificationWithResponse
(com.azure.core.util.Context context) Posts a typing event to a thread, on behalf of a user.void
updateMessage
(String chatMessageId, UpdateChatMessageOptions options) Updates a message.com.azure.core.http.rest.Response
<Void> updateMessageWithResponse
(String chatMessageId, UpdateChatMessageOptions options, com.azure.core.util.Context context) Updates a message.void
updateTopic
(String topic) Updates a thread's topic.com.azure.core.http.rest.Response
<Void> updateTopicWithResponse
(String topic, com.azure.core.util.Context context) Updates a thread's topic.
-
Method Details
-
getChatThreadId
Get the thread id property.- Returns:
- the thread id value.
-
updateTopic
Updates a thread's topic.- Parameters:
topic
- The new topic.- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
updateTopicWithResponse
public com.azure.core.http.rest.Response<Void> updateTopicWithResponse(String topic, com.azure.core.util.Context context) Updates a thread's topic.- Parameters:
topic
- The new topic.context
- The context to associate with this operation.- 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:
- AddChatParticipantsResult.
- 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 com.azure.core.http.rest.Response<AddChatParticipantsResult> addParticipantsWithResponse(Iterable<ChatParticipant> participants, com.azure.core.util.Context context) Adds participants to a thread. If participants already exist, no change occurs.- Parameters:
participants
- Collection of participants to add.context
- The context to associate with this operation.- Returns:
- the response.
- 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.- 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
public com.azure.core.http.rest.Response<Void> addParticipantWithResponse(ChatParticipant participant, com.azure.core.util.Context context) Adds a participant to a thread. If the participant already exists, no change occurs.- Parameters:
participant
- The new participant.context
- The context to associate with this operation.- 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.
-
removeParticipantWithResponse
public com.azure.core.http.rest.Response<Void> removeParticipantWithResponse(CommunicationIdentifier identifier, com.azure.core.util.Context context) Remove a participant from a thread.- Parameters:
identifier
- Identity of the participant to remove from the thread.context
- The context to associate with this operation.- 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.
-
removeParticipant
Remove a participant from a thread.- Parameters:
identifier
- Identity of the thread participant to remove from the 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.- 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
public com.azure.core.http.rest.PagedIterable<ChatParticipant> listParticipants(ListParticipantsOptions listParticipantsOptions, com.azure.core.util.Context context) Gets the participants of a thread.- Parameters:
listParticipantsOptions
- The request options.context
- The context to associate with this operation.- 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.
-
sendMessageWithResponse
public com.azure.core.http.rest.Response<SendChatMessageResult> sendMessageWithResponse(SendChatMessageOptions options, com.azure.core.util.Context context) Sends a message to a thread.- Parameters:
options
- Options for sending the message.context
- The context to associate with this operation.- 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.
-
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); 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.
-
getMessageWithResponse
public com.azure.core.http.rest.Response<ChatMessage> getMessageWithResponse(String chatMessageId, com.azure.core.util.Context context) Gets a message by id.- Parameters:
chatMessageId
- The message id.context
- The context to associate with this operation.- 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.
-
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.
-
listMessages
Gets a list of messages from a thread.- Returns:
- a 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
public com.azure.core.http.rest.PagedIterable<ChatMessage> listMessages(ListChatMessagesOptions listMessagesOptions, com.azure.core.util.Context context) Gets a list of messages from a thread.- Parameters:
listMessagesOptions
- The request options.context
- The context to associate with this operation.- Returns:
- a 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.
-
updateMessageWithResponse
public com.azure.core.http.rest.Response<Void> updateMessageWithResponse(String chatMessageId, UpdateChatMessageOptions options, com.azure.core.util.Context context) Updates a message.- Parameters:
chatMessageId
- The message id.options
- Options for updating the message.context
- The context to associate with this operation.- 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.
-
updateMessage
Updates a message.- Parameters:
chatMessageId
- The message id.options
- Options for updating the message.- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
deleteMessageWithResponse
public com.azure.core.http.rest.Response<Void> deleteMessageWithResponse(String chatMessageId, com.azure.core.util.Context context) Deletes a message.- Parameters:
chatMessageId
- The message id.context
- The context to associate with this operation.- 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.- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendTypingNotificationWithResponse
public com.azure.core.http.rest.Response<Void> sendTypingNotificationWithResponse(com.azure.core.util.Context context) Posts a typing event to a thread, on behalf of a user.- Parameters:
context
- The context to associate with this operation.- 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
public void sendTypingNotification()Posts a typing event to a thread, on behalf of a user.- Throws:
ChatErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
sendTypingNotificationWithResponse
public com.azure.core.http.rest.Response<Void> sendTypingNotificationWithResponse(TypingNotificationOptions options, com.azure.core.util.Context context) Posts a typing event to a thread, on behalf of a user.- Parameters:
options
- Options for sending the typing notification.context
- The context to associate with this operation.- 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
public com.azure.core.http.rest.Response<Void> sendReadReceiptWithResponse(String chatMessageId, com.azure.core.util.Context context) Posts a read receipt event to a thread, on behalf of a user.- Parameters:
chatMessageId
- The id of the chat message that was read.context
- The context to associate with this operation.- 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.- 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 com.azure.core.http.rest.PagedIterable<ChatMessageReadReceipt> listReadReceipts(ListReadReceiptOptions listReadReceiptOptions, com.azure.core.util.Context context) Gets read receipts for a thread.- Parameters:
listReadReceiptOptions
- The additional options for this operation.context
- The context to associate with this operation.- 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.
-
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
public com.azure.core.http.rest.Response<ChatThreadProperties> getPropertiesWithResponse(com.azure.core.util.Context context) Gets chat thread properties.- Parameters:
context
- The context to associate with this operation.- 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.
-