use of com.azure.android.communication.chat.models.ListReadReceiptOptions in project azure-sdk-for-android by Azure.
the class MainActivity method listReadReceipts.
public void listReadReceipts(View view) {
if (chatThreadAsyncClient == null) {
createChatThreadAsyncClient();
}
if (chatThreadAsyncClient != null) {
// The maximum number of read receipts to be returned per page, optional.
int maxPageSize = 10;
// Skips participants up to a specified position in response.
int skip = 0;
// Options to pass to the list method.
ListReadReceiptOptions listReadReceiptOptions = new ListReadReceiptOptions().setMaxPageSize(maxPageSize).setSkip(skip);
try {
PagedAsyncStream<ChatMessageReadReceipt> readReceipts = chatThreadAsyncClient.listReadReceipts(listReadReceiptOptions, RequestContext.NONE);
readReceipts.forEach(readReceipt -> {
Log.d(TAG, "Got receipt for participant " + ((CommunicationUserIdentifier) readReceipt.getSenderCommunicationIdentifier()).getId() + " for message with id: " + readReceipt.getChatMessageId());
});
} catch (Exception e) {
logAndToast("Listing read receipts failed: " + e.getMessage());
}
} else {
logAndToast("ChatThreadAsyncClient creation failed");
}
}
use of com.azure.android.communication.chat.models.ListReadReceiptOptions in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method canListReadReceipts.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canListReadReceipts(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupMockTest();
PagedAsyncStream<ChatMessageReadReceipt> readReceiptPagedAsyncStream = this.chatThreadClient.listReadReceipts(new ListReadReceiptOptions(), null);
CountDownLatch latch = new CountDownLatch(1);
List<ChatMessageReadReceipt> readReceiptList = new ArrayList<ChatMessageReadReceipt>();
readReceiptPagedAsyncStream.forEach(new AsyncStreamHandler<ChatMessageReadReceipt>() {
@Override
public void onNext(ChatMessageReadReceipt readReceipt) {
readReceiptList.add(readReceipt);
}
@Override
public void onError(Throwable throwable) {
latch.countDown();
}
@Override
public void onComplete() {
latch.countDown();
}
});
awaitOnLatch(latch, "canListReadReceipts");
assertEquals(readReceiptList.size(), 2);
assertNotNull(readReceiptList.get(0).getChatMessageId());
assertNotNull(readReceiptList.get(0).getReadOn());
assertNotNull(readReceiptList.get(0).getSenderCommunicationIdentifier());
}
use of com.azure.android.communication.chat.models.ListReadReceiptOptions in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method canListReadReceiptsWithOptions.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canListReadReceiptsWithOptions(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupMockTest();
PagedAsyncStream<ChatMessageReadReceipt> readReceiptPagedAsyncStream = this.chatThreadClient.listReadReceipts(new ListReadReceiptOptions(), null);
CountDownLatch latch = new CountDownLatch(1);
List<ChatMessageReadReceipt> readReceiptList = new ArrayList<ChatMessageReadReceipt>();
readReceiptPagedAsyncStream.forEach(new AsyncStreamHandler<ChatMessageReadReceipt>() {
@Override
public void onNext(ChatMessageReadReceipt readReceipt) {
readReceiptList.add(readReceipt);
}
@Override
public void onError(Throwable throwable) {
latch.countDown();
}
@Override
public void onComplete() {
latch.countDown();
}
});
awaitOnLatch(latch, "canListReadReceiptsWithOptions");
assertEquals(readReceiptList.size(), 2);
assertNotNull(readReceiptList.get(0).getChatMessageId());
assertNotNull(readReceiptList.get(0).getReadOn());
assertNotNull(readReceiptList.get(0).getSenderCommunicationIdentifier());
}
Aggregations