ChatThreadClient Class
- java.
lang. Object - com.
azure. communication. chat. ChatThreadClient
- com.
public final class 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 ChatClientBuilder for additional ways to construct the client.
Method Summary
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:
addParticipants
public AddChatParticipantsResult addParticipants(Iterable<ChatParticipant> participants)
Adds participants to a thread. If participants already exist, no change occurs.
Parameters:
Returns:
addParticipantsWithResponse
public Response<AddChatParticipantsResult> addParticipantsWithResponse(Iterable<ChatParticipant> participants, Context context)
Adds participants to a thread. If participants already exist, no change occurs.
Parameters:
Returns:
addParticipantWithResponse
public Response<Void> addParticipantWithResponse(ChatParticipant participant, Context context)
Adds a participant to a thread. If the participant already exists, no change occurs.
Parameters:
Returns:
deleteMessage
public void deleteMessage(String chatMessageId)
Deletes a message.
Parameters:
deleteMessageWithResponse
public Response<Void> deleteMessageWithResponse(String chatMessageId, Context context)
Deletes a message.
Parameters:
Returns:
getChatThreadId
public String getChatThreadId()
Get the thread id property.
Returns:
getMessage
public ChatMessage getMessage(String chatMessageId)
Gets a message by id.
Parameters:
Returns:
getMessageWithResponse
public Response<ChatMessage> getMessageWithResponse(String chatMessageId, Context context)
Gets a message by id.
Parameters:
Returns:
getProperties
public ChatThreadProperties getProperties()
Gets chat thread properties.
Returns:
getPropertiesWithResponse
public Response<ChatThreadProperties> getPropertiesWithResponse(Context context)
Gets chat thread properties.
Parameters:
Returns:
listMessages
public PagedIterable<ChatMessage> listMessages()
Gets a list of messages from a thread.
Returns:
listMessages
public PagedIterable<ChatMessage> listMessages(ListChatMessagesOptions listMessagesOptions, Context context)
Gets a list of messages from a thread.
Parameters:
Returns:
listParticipants
public PagedIterable<ChatParticipant> listParticipants()
Gets the participants of a thread.
Returns:
listParticipants
public PagedIterable<ChatParticipant> listParticipants(ListParticipantsOptions listParticipantsOptions, Context context)
Gets the participants of a thread.
Parameters:
Returns:
listReadReceipts
public PagedIterable<ChatMessageReadReceipt> listReadReceipts()
Gets read receipts for a thread.
Returns:
listReadReceipts
public PagedIterable<ChatMessageReadReceipt> listReadReceipts(ListReadReceiptOptions listReadReceiptOptions, Context context)
Gets read receipts for a thread.
Parameters:
Returns:
removeParticipant
public void removeParticipant(CommunicationIdentifier identifier)
Remove a participant from a thread.
Parameters:
removeParticipantWithResponse
public Response<Void> removeParticipantWithResponse(CommunicationIdentifier identifier, Context context)
Remove a participant from a thread.
Parameters:
Returns:
sendMessage
public 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);
String messageId = sendResult.getId();
Parameters:
Returns:
sendMessageWithResponse
public Response<SendChatMessageResult> sendMessageWithResponse(SendChatMessageOptions options, Context context)
Sends a message to a thread.
Parameters:
Returns:
sendReadReceipt
public void sendReadReceipt(String chatMessageId)
Posts a read receipt event to a thread, on behalf of a user.
Parameters:
sendReadReceiptWithResponse
public Response<Void> sendReadReceiptWithResponse(String chatMessageId, Context context)
Posts a read receipt event to a thread, on behalf of a user.
Parameters:
Returns:
sendTypingNotification
public void sendTypingNotification()
Posts a typing event to a thread, on behalf of a user.
sendTypingNotificationWithResponse
public Response<Void> sendTypingNotificationWithResponse(Context context)
Posts a typing event to a thread, on behalf of a user.
Parameters:
Returns:
sendTypingNotificationWithResponse
public Response<Void> sendTypingNotificationWithResponse(TypingNotificationOptions options, Context context)
Posts a typing event to a thread, on behalf of a user.
Parameters:
Returns:
updateMessage
public void updateMessage(String chatMessageId, UpdateChatMessageOptions options)
Updates a message.
Parameters:
updateMessageWithResponse
public Response<Void> updateMessageWithResponse(String chatMessageId, UpdateChatMessageOptions options, Context context)
Updates a message.
Parameters:
Returns:
updateThreadProperties
public void updateThreadProperties(UpdateChatThreadOptions options)
Updates a thread's properties.
Parameters:
updateThreadPropertiesWithResponse
public Response<Void> updateThreadPropertiesWithResponse(UpdateChatThreadOptions options, Context context)
Updates a thread's properties.
Parameters:
Returns:
updateTopic
public void updateTopic(String topic)
Updates a thread's topic.
Parameters:
updateTopicWithResponse
public Response<Void> updateTopicWithResponse(String topic, Context context)
Updates a thread's topic.
Parameters:
Returns: