* Update README.md
* Update root README.md

Co-authored-by: Marc Ma <marcma@microsoft.com>
This commit is contained in:
marche0133 2021-02-22 18:32:01 -08:00 коммит произвёл GitHub
Родитель 0fa3e4ae44
Коммит 7c5c2a5b96
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 34 добавлений и 21 удалений

Просмотреть файл

@ -16,7 +16,8 @@ For your convenience, each service has a separate set of libraries that you can
### Libraries available
Currently, the client libraries are in **beta**. These libraries follow the [Azure SDK Design Guidelines for Android](https://azure.github.io/azure-sdk/android_introduction.html) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features in [azure-core](https://github.com/Azure/azure-sdk-for-android/blob/master/sdk/core/azure-core/README.md).
Currently, the client libraries are in **beta**. These libraries follow the [Azure SDK
Guidelines for Android](https://azure.github.io/azure-sdk/android_design.html) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features in [azure-core](https://github.com/Azure/azure-sdk-for-android/blob/master/sdk/core/azure-core/README.md).
The following libraries are currently in **beta**:
@ -25,8 +26,8 @@ The following libraries are currently in **beta**:
#### Azure Communication Services
- [azure-communication-calling](https://search.maven.org/artifact/com.azure.android/azure-communication-calling): 1.0.0-beta.2
- [azure-communication-chat](https://github.com/Azure/azure-sdk-for-android/blob/master/sdk/communication/azure-communication-chat): 1.0.0-beta.2
- [azure-communication-common](https://github.com/Azure/azure-sdk-for-android/blob/master/sdk/communication/azure-communication-common): 1.0.0-beta.1
- [azure-communication-chat](https://github.com/Azure/azure-sdk-for-android/blob/master/sdk/communication/azure-communication-chat): 1.0.0-beta.5
- [azure-communication-common](https://github.com/Azure/azure-sdk-for-android/blob/master/sdk/communication/azure-communication-common): 1.0.0-beta.5
> Note: The SDK is currently in **beta**. The API surface and feature sets are subject to change at any time before they become generally available. We do not currently recommend them for production use.
@ -44,13 +45,13 @@ For each library you wish to use, add an `implementation` configuration to the `
// build.gradle
dependencies {
...
implementation "com.azure.android:azure-communication-chat:1.0.0-beta.2"
implementation "com.azure.android:azure-communication-chat:1.0.0-beta.5"
}
// build.gradle.kts
dependencies {
...
implementation("com.azure.android:azure-communication-chat:1.0.0-beta.2")
implementation("com.azure.android:azure-communication-chat:1.0.0-beta.5")
}
```
@ -61,7 +62,7 @@ To import one or more client libraries into your project using the [Maven](https
<dependency>
<groupId>com.azure.android</groupId>
<artifactId>azure-communication-chat</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.5</version>
</dependency>
```

Просмотреть файл

@ -56,18 +56,18 @@ To import the library into your project using the [Maven](https://maven.apache.o
</dependency>
```
### Create the AzureCommunicationChatClient
### Create the ChatClient
Use the `AzureCommunicationChatServiceAsyncClient.Builder` to configure and create an instance of `AzureCommunicationChatClient`.
Use the `ChatAsyncClient.Builder` to configure and create an instance of `ChatAsyncClient`.
```java
import com.azure.android.communication.chat.AzureCommunicationChatServiceAsyncClient;
import com.azure.android.communication.chat.ChatAsyncClient;
import com.azure.android.core.http.HttpHeader;
final String endpoint = "https://<resource>.communication.azure.com";
final String userAccessToken = "<user_access_token>";
AzureCommunicationChatServiceAsyncClient client = new AzureCommunicationChatServiceAsyncClient.Builder()
ChatAsyncClient client = new ChatAsyncClient.Builder()
.endpoint(endpoint)
.credentialInterceptor(chain -> chain.proceed(chain.request()
.newBuilder()
@ -75,6 +75,18 @@ AzureCommunicationChatServiceAsyncClient client = new AzureCommunicationChatServ
.build());
```
### Create the ChatThreadClient
Now that we've created a Chat thread we'll obtain a `ChatThreadClient` to perform operations within the thread.
```
ChatThreadClient chatThreadClient =
new ChatThreadClient.Builder()
.endpoint(<endpoint>))
.build();
```
Replace `<endpoint>` with your Communication Services endpoint.
## Key concepts
### Users and User Access Tokens
@ -310,7 +322,7 @@ SendChatMessageRequest message = new SendChatMessageRequest()
// The unique ID of the thread.
final String threadId = "<thread_id>";
client.sendChatMessage(threadId, message, new Callback<String>() {
chatThreadClient.sendChatMessage(threadId, message, new Callback<String>() {
@Override
public void onSuccess(String messageId, Response response) {
// A string is the response returned from sending a message, it is an id,
@ -336,7 +348,7 @@ final String threadId = "<thread_id>";
// The unique ID of the message.
final String chatMessageId = "<message_id>";
client.getChatMessage(threadId, chatMessageId, new Callback<ChatMessage>() {
chatThreadClient.getChatMessage(threadId, chatMessageId, new Callback<ChatMessage>() {
@Override
public void onSuccess(ChatMessage chatMessage, Response response) {
// `ChatMessage` is the response returned from getting a message.
@ -363,7 +375,7 @@ final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-08T00:00:00Z");
// The unique ID of the thread.
final String threadId = "<thread_id>";
client.listChatMessagesPages(threadId,
chatThreadClient.listChatMessagesPages(threadId,
maxPageSize,
startTime,
new Callback<AsyncPagedDataCollection<ChatMessage, Page<ChatMessage>>>() {
@ -427,7 +439,7 @@ UpdateChatMessageRequest message = new UpdateChatMessageRequest()
final String threadId = "<thread_id>";
// The unique ID of the message.
final String messageId = "<message_id>";
client.updateChatMessage(threadId, messageId, message, new Callback<Void>() {
chatThreadClient.updateChatMessage(threadId, messageId, message, new Callback<Void>() {
@Override
public void onSuccess(Void result, Response response) {
// Take further action.
@ -449,7 +461,7 @@ Use the `deleteChatMessage` method to delete a message in a thread.
final String threadId = "<thread_id>";
// The unique ID of the message.
final String messageId = "<message_id>";
client.deleteChatMessage(threadId, messageId, new Callback<Void>() {
chatThreadClient.deleteChatMessage(threadId, messageId, new Callback<Void>() {
@Override
public void onSuccess(Void result, Response response) {
// Take further action.
@ -478,7 +490,7 @@ final int maxPageSize = 10;
// Skips participants up to a specified position in response.
final int skip = 0;
client.listChatParticipantsPages(threadId,
chatThreadClient.listChatParticipantsPages(threadId,
maxPageSize,
skip,
new Callback<AsyncPagedDataCollection<ChatParticipant, Page<ChatParticipant>>>() {
@ -545,7 +557,7 @@ AddChatParticipantsRequest participants = new AddChatParticipantsRequest()
// The unique ID of the thread.
final String threadId = "<thread_id>";
client.addChatParticipants(threadId, participants, new Callback<Void>() {
chatThreadClient.addChatParticipants(threadId, participants, new Callback<Void>() {
@Override
public void onSuccess(Void result, Response response) {
// Take further action.
@ -567,7 +579,7 @@ Use the `removeChatParticipant` method to remove a participant from a thread.
final String threadId = "<thread_id>";
// The unique ID of the participant.
final String participantId = "<participant_id>";
client.removeChatParticipant(threadId, participantId, new Callback<Void>() {
chatThreadClient.removeChatParticipant(threadId, participantId, new Callback<Void>() {
@Override
public void onSuccess(Void result, Response response) {
// Take further action.
@ -589,7 +601,7 @@ Use the `sendTypingNotification` method to post a typing notification event to a
```java
// The unique ID of the thread.
final String threadId = "<thread_id>";
client.sendTypingNotification(threadId, new Callback<Void>() {
chatThreadClient.sendTypingNotification(threadId, new Callback<Void>() {
@Override
public void onSuccess(Void result, Response response) {
// Take further action.
@ -615,7 +627,7 @@ SendReadReceiptRequest readReceipt = new SendReadReceiptRequest()
// The unique ID of the thread.
final String threadId = "<thread_id>";
client.sendChatReadReceipt(threadId, readReceipt, new Callback<Void>() {
chatThreadClient.sendChatReadReceipt(threadId, readReceipt, new Callback<Void>() {
@Override
public void onSuccess(Void result, Response response) {
// Take further action.
@ -642,7 +654,7 @@ final int maxPageSize = 10;
// Skips participants up to a specified position in response.
final int skip = 0;
client.listChatReadReceiptsPages(threadId,
chatThreadClient.listChatReadReceiptsPages(threadId,
maxPageSize,
skip,
new Callback<AsyncPagedDataCollection<ChatMessageReadReceipt, Page<ChatMessageReadReceipt>>>() {