Class ChatThreadAsyncClient

java.lang.Object
com.azure.communication.chat.ChatThreadAsyncClient

public final class ChatThreadAsyncClient extends Object
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 Details

    • getChatThreadId

      public String getChatThreadId()
      Get the thread id property.
      Returns:
      the thread id value.
    • updateTopic

      public Mono<Void> updateTopic(String topic)
      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

      public Mono<Response<Void>> updateTopicWithResponse(String topic)
      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

      public Mono<AddChatParticipantsResult> addParticipants(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.
    • 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

      public Mono<Void> addParticipant(ChatParticipant participant)
      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

      public Mono<Response<Void>> addParticipantWithResponse(ChatParticipant participant)
      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

      public Mono<Void> removeParticipant(CommunicationIdentifier identifier)
      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

      public Mono<Response<Void>> removeParticipantWithResponse(CommunicationIdentifier identifier)
      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

      public PagedFlux<ChatParticipant> 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 PagedFlux<ChatParticipant> listParticipants(ListParticipantsOptions listParticipantsOptions)
      Gets the participants of a thread.
      Parameters:
      listParticipantsOptions - The request options.
      Returns:
      the participants of a thread.
    • sendMessage

      public Mono<SendChatMessageResult> sendMessage(SendChatMessageOptions options)
      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

      public Mono<ChatMessage> getMessage(String chatMessageId)
      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

      public Mono<Response<ChatMessage>> getMessageWithResponse(String chatMessageId)
      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

      public PagedFlux<ChatMessage> 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

      public PagedFlux<ChatMessage> listMessages(ListChatMessagesOptions listMessagesOptions)
      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

      public Mono<Void> updateMessage(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.
    • 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

      public Mono<Void> deleteMessage(String chatMessageId)
      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

      public Mono<Response<Void>> deleteMessageWithResponse(String chatMessageId)
      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

      public Mono<Void> 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

      public Mono<Response<Void>> 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

      public Mono<Response<Void>> sendTypingNotificationWithResponse(TypingNotificationOptions options)
      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

      public Mono<Void> sendReadReceipt(String chatMessageId)
      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

      public Mono<Response<Void>> sendReadReceiptWithResponse(String chatMessageId)
      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

      public PagedFlux<ChatMessageReadReceipt> 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

      public Mono<ChatThreadProperties> 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 Mono<Response<ChatThreadProperties>> 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.