ChatThreadClient Class

  • java.lang.Object
    • com.azure.communication.chat.ChatThreadClient

public final class ChatThreadClient

Sync Client that supports chat thread operations.

Instantiating a synchronous Chat Thread Client

Java
// 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 ChatClientBuilder for additional ways to construct the client.

Method Summary

Modifier and Type Method and Description
void addParticipant(ChatParticipant participant)

Adds a participant to a thread.

AddChatParticipantsResult addParticipants(Iterable<ChatParticipant> participants)

Adds participants to a thread.

Response<AddChatParticipantsResult> addParticipantsWithResponse(Iterable<ChatParticipant> participants, Context context)

Adds participants to a thread.

Response<Void> addParticipantWithResponse(ChatParticipant participant, Context context)

Adds a participant to a thread.

void deleteMessage(String chatMessageId)

Deletes a message.

Response<Void> deleteMessageWithResponse(String chatMessageId, Context context)

Deletes a message.

String getChatThreadId()

Get the thread id property.

ChatMessage getMessage(String chatMessageId)

Gets a message by id.

Response<ChatMessage> getMessageWithResponse(String chatMessageId, Context context)

Gets a message by id.

ChatThreadProperties getProperties()

Gets chat thread properties.

Response<ChatThreadProperties> getPropertiesWithResponse(Context context)

Gets chat thread properties.

PagedIterable<ChatMessage> listMessages()

Gets a list of messages from a thread.

PagedIterable<ChatMessage> listMessages(ListChatMessagesOptions listMessagesOptions, Context context)

Gets a list of messages from a thread.

PagedIterable<ChatParticipant> listParticipants()

Gets the participants of a thread.

PagedIterable<ChatParticipant> listParticipants(ListParticipantsOptions listParticipantsOptions, Context context)

Gets the participants of a thread.

PagedIterable<ChatMessageReadReceipt> listReadReceipts()

Gets read receipts for a thread.

PagedIterable<ChatMessageReadReceipt> listReadReceipts(ListReadReceiptOptions listReadReceiptOptions, Context context)

Gets read receipts for a thread.

void removeParticipant(CommunicationIdentifier identifier)

Remove a participant from a thread.

Response<Void> removeParticipantWithResponse(CommunicationIdentifier identifier, Context context)

Remove a participant from a thread.

SendChatMessageResult sendMessage(SendChatMessageOptions options)

Sends a message to a thread.

Response<SendChatMessageResult> sendMessageWithResponse(SendChatMessageOptions options, 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.

Response<Void> sendReadReceiptWithResponse(String chatMessageId, Context context)

Posts a read receipt event to a thread, on behalf of a user.

void sendTypingNotification()

Posts a typing event to a thread, on behalf of a user.

Response<Void> sendTypingNotificationWithResponse(Context context)

Posts a typing event to a thread, on behalf of a user.

Response<Void> sendTypingNotificationWithResponse(TypingNotificationOptions options, Context context)

Posts a typing event to a thread, on behalf of a user.

void updateMessage(String chatMessageId, UpdateChatMessageOptions options)

Updates a message.

Response<Void> updateMessageWithResponse(String chatMessageId, UpdateChatMessageOptions options, Context context)

Updates a message.

void updateTopic(String topic)

Updates a thread's topic.

Response<Void> updateTopicWithResponse(String topic, Context context)

Updates a thread's topic.

Methods inherited from java.lang.Object

Method Details

addParticipant

public void addParticipant(ChatParticipant participant)

Adds a participant to a thread. If the participant already exists, no change occurs.

Parameters:

participant - The new participant.

addParticipants

public AddChatParticipantsResult addParticipants(Iterable participants)

Adds participants to a thread. If participants already exist, no change occurs.

Parameters:

participants - Collection of participants to add.

Returns:

AddChatParticipantsResult.

addParticipantsWithResponse

public Response addParticipantsWithResponse(Iterable participants, 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.

addParticipantWithResponse

public Response addParticipantWithResponse(ChatParticipant participant, 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.

deleteMessage

public void deleteMessage(String chatMessageId)

Deletes a message.

Parameters:

chatMessageId - The message id.

deleteMessageWithResponse

public Response deleteMessageWithResponse(String chatMessageId, Context context)

Deletes a message.

Parameters:

chatMessageId - The message id.
context - The context to associate with this operation.

Returns:

the completion.

getChatThreadId

public String getChatThreadId()

Get the thread id property.

Returns:

the thread id value.

getMessage

public ChatMessage getMessage(String chatMessageId)

Gets a message by id.

Parameters:

chatMessageId - The message id.

Returns:

a message by id.

getMessageWithResponse

public Response getMessageWithResponse(String chatMessageId, 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.

getProperties

public ChatThreadProperties getProperties()

Gets chat thread properties.

Returns:

chat thread properties.

getPropertiesWithResponse

public Response getPropertiesWithResponse(Context context)

Gets chat thread properties.

Parameters:

context - The context to associate with this operation.

Returns:

chat thread properties.

listMessages

public PagedIterable listMessages()

Gets a list of messages from a thread.

Returns:

a list of messages from a thread.

listMessages

public PagedIterable listMessages(ListChatMessagesOptions listMessagesOptions, 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.

listParticipants

public PagedIterable listParticipants()

Gets the participants of a thread.

Returns:

the participants of a thread.

listParticipants

public PagedIterable listParticipants(ListParticipantsOptions listParticipantsOptions, 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.

listReadReceipts

public PagedIterable listReadReceipts()

Gets read receipts for a thread.

Returns:

read receipts for a thread.

listReadReceipts

public PagedIterable listReadReceipts(ListReadReceiptOptions listReadReceiptOptions, 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.

removeParticipant

public void removeParticipant(CommunicationIdentifier identifier)

Remove a participant from a thread.

Parameters:

identifier - Identity of the thread participant to remove from the thread.

removeParticipantWithResponse

public Response removeParticipantWithResponse(CommunicationIdentifier identifier, 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.

sendMessage

public SendChatMessageResult sendMessage(SendChatMessageOptions options)

Sends a message to a thread.

Code Samples

Send a chat message based on "options".

Java
// 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.

sendMessageWithResponse

public Response sendMessageWithResponse(SendChatMessageOptions options, 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.

sendReadReceipt

public 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.

sendReadReceiptWithResponse

public Response sendReadReceiptWithResponse(String chatMessageId, 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.

sendTypingNotification

public void sendTypingNotification()

Posts a typing event to a thread, on behalf of a user.

sendTypingNotificationWithResponse

public Response sendTypingNotificationWithResponse(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.

sendTypingNotificationWithResponse

public Response sendTypingNotificationWithResponse(TypingNotificationOptions options, 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.

updateMessage

public void updateMessage(String chatMessageId, UpdateChatMessageOptions options)

Updates a message.

Parameters:

chatMessageId - The message id.
options - Options for updating the message.

updateMessageWithResponse

public Response updateMessageWithResponse(String chatMessageId, UpdateChatMessageOptions options, 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.

updateTopic

public void updateTopic(String topic)

Updates a thread's topic.

Parameters:

topic - The new topic.

updateTopicWithResponse

public Response updateTopicWithResponse(String topic, Context context)

Updates a thread's topic.

Parameters:

topic - The new topic.
context - The context to associate with this operation.

Returns:

the completion.

Applies to

Azure SDK for Java

Latest