11# Azure Communication Chat client library for .NET
22
3- > Server Version:
4- Chat client: 2020-09-21-preview2
3+ > Server - Chat Api Version: 2020-11-01-preview3
4+ > Client - Chat SDK Version: 1.0.0-beta.3
55
66This package contains a C# SDK for Azure Communication Services for chat.
77
@@ -37,8 +37,6 @@ For the generation of user access tokens, refer to [User Access Tokens][useracce
3737
3838### Using statements
3939``` C# Snippet:Azure_Communication_Chat_Tests_E2E_UsingStatements
40- using Azure .Core ;
41- using Azure .Communication ;
4240using Azure .Communication .Identity ;
4341using Azure .Communication .Chat ;
4442```
@@ -54,19 +52,17 @@ ChatClient chatClient = new ChatClient(
5452
5553### Create a ChatThreadClient
5654
57- The ChatThreadClient will allow you to perform operations specific to a chat thread, like update the chat thread topic, send a message, add members to the chat thread, etc.
55+ The ChatThreadClient will allow you to perform operations specific to a chat thread, like update the chat thread topic, send a message, add participants to the chat thread, etc.
5856
5957You can instantiate a new ChatThreadClient instance using the ChatClient:
6058
6159``` C# Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
62- ChatThreadClient chatThreadClient1 = chatClient .CreateChatThread (" Thread topic" , members );
63- // Alternatively, if you have created a chat thread before and you have its threadId, you can create a ChatThreadClient instance using:
64- ChatThreadClient chatThreadClient2 = chatClient .GetChatThreadClient (" threadId" );
60+ ChatThreadClient chatThreadClient = chatClient .GetChatThreadClient (" threadId" );
6561```
6662
6763## Key concepts
6864
69- A chat conversation is represented by a thread. Each user in the thread is called a thread member . Thread members can chat with one another privately in a 1:1 chat or huddle up in a 1: N group chat. Users also get near-real time updates for when others are typing and when they have read the messages.
65+ A chat conversation is represented by a thread. Each user in the thread is called a thread participant . Thread participants can chat with one another privately in a 1:1 chat or huddle up in a 1: N group chat. Users also get near-real time updates for when others are typing and when they have read the messages.
7066
7167Once you initialized a ` ChatClient ` class, you can do the following chat operations:
7268
@@ -91,12 +87,12 @@ Once you initialized a `ChatThreadClient` class, you can do the following chat o
9187### Update a thread
9288
9389``` C# Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread
94- chatThreadClient .UpdateThread (topic : " Launch meeting" );
90+ chatThreadClient .UpdateTopic (topic : " Launch meeting" );
9591```
9692
9793### Send a message
9894``` C# Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
99- SendChatMessageResult sendChatMessageResult = chatThreadClient .SendMessage (" Let's meet at 11am" );
95+ string messageId = chatThreadClient .SendMessage (" Let's meet at 11am" );
10096```
10197### Update a message
10298``` C# Snippet:Azure_Communication_Chat_Tests_E2E_UpdateMessage
@@ -114,25 +110,25 @@ Pageable<ChatMessage> messages = chatThreadClient.GetMessages();
114110``` C# Snippet:Azure_Communication_Chat_Tests_E2E_DeleteMessage
115111chatThreadClient .DeleteMessage (messageId );
116112```
117- ### Get a list of members
118- ``` C# Snippet:Azure_Communication_Chat_Tests_E2E_GetMembers
119- Pageable < ChatThreadMember > chatThreadMembers = chatThreadClient .GetMembers ();
113+ ### Get a list of participants
114+ ``` C# Snippet:Azure_Communication_Chat_Tests_E2E_GetParticipants
115+ Pageable < ChatParticipant > chatParticipants = chatThreadClient .GetParticipants ();
120116```
121- ### Add members
122- ``` C# Snippet:Azure_Communication_Chat_Tests_E2E_AddMembers
123- chatThreadClient .AddMembers ( members : new [] { newMember });
117+ ### Add participants
118+ ``` C# Snippet:Azure_Communication_Chat_Tests_E2E_AddParticipants
119+ chatThreadClient .AddParticipants ( participants : new [] { newParticipant });
124120```
125- ### Remove a member
126- ``` C# Snippet:Azure_Communication_Chat_Tests_E2E_RemoveMember
127- chatThreadClient .RemoveMember (user : memberToBeRemoved );
121+ ### Remove a participant
122+ ``` C# Snippet:Azure_Communication_Chat_Tests_E2E_RemoveParticipant
123+ chatThreadClient .RemoveParticipant (user : participantToBeRemoved );
128124```
129125### Send a typing notification
130126``` C# Snippet:Azure_Communication_Chat_Tests_E2E_SendTypingNotification
131127chatThreadClient .SendTypingNotification ();
132128```
133129### Get a list of read receipts
134130``` C# Snippet:Azure_Communication_Chat_Tests_E2E_GetReadReceipts
135- Pageable < ReadReceipt > readReceipts = chatThreadClient .GetReadReceipts ();
131+ Pageable < ChatMessageReadReceipt > readReceipts = chatThreadClient .GetReadReceipts ();
136132```
137133### Send a read receipt
138134``` C# Snippet:Azure_Communication_Chat_Tests_E2E_SendReadReceipt
@@ -144,7 +140,7 @@ The following sections provide several code snippets covering some of the most c
144140
145141- [ Thread Operations] ( #thread-operations )
146142- [ Message Operations] ( #message-operations )
147- - [ Thread Member Operations] ( #thread-member -operations )
143+ - [ Thread Participant Operations] ( #thread-participant -operations )
148144- [ Events Operations] ( #events-operations )
149145
150146## Thread Operations
@@ -153,27 +149,28 @@ The following sections provide several code snippets covering some of the most c
153149
154150Use ` CreateChatThread ` to create a chat thread client object.
155151- Use ` topic ` to give a thread topic.
156- - The following are the supported attributes for each thread member :
157- - ` communicationUser ` , required, it is the identification for the thread member .
158- - ` displayName ` , optional, is the display name for the thread member
159- - ` shareHistoryTime ` , optional, time from which the chat history is shared with the member .
152+ - The following are the supported attributes for each thread participant :
153+ - ` communicationUser ` , required, it is the identification for the thread participant .
154+ - ` displayName ` , optional, is the display name for the thread participant
155+ - ` shareHistoryTime ` , optional, time from which the chat history is shared with the participant .
160156
161157` ChatThreadClient ` is the result returned from creating a thread, you can use it to perform other operations on the chat thread.
162158
163- ** Important:** Make sure the user creating the chat thread is explicitely added to the list of members , otherwise the creation call will fail.
159+ ** Important:** Make sure the user creating the chat thread is explicitely added to the list of participants , otherwise the creation call will fail.
164160
165161``` C# Snippet:Azure_Communication_Chat_Tests_Samples_CreateChatClient
166162ChatClient chatClient = new ChatClient (
167163 new Uri (endpoint ),
168164 new CommunicationTokenCredential (userToken ));
169165```
170166``` C# Snippet:Azure_Communication_Chat_Tests_Samples_CreateThread
171- var chatThreadMember = new ChatThreadMember ( new CommunicationUserIdentifier ( threadCreatorId ) )
167+ var chatParticipant = new ChatParticipant ( threadCreator )
172168{
173169 DisplayName = " UserDisplayName"
174170};
175- ChatThreadClient chatThreadClient = await chatClient .CreateChatThreadAsync (topic : " Hello world!" , members : new [] { chatThreadMember });
176- string threadId = chatThreadClient .Id ;
171+ CreateChatThreadResult createChatThreadResult = await chatClient .CreateChatThreadAsync (topic : " Hello world!" , participants : new [] { chatParticipant });
172+ string threadId = createChatThreadResult .ChatThread .Id ;
173+ ChatThreadClient chatThreadClient = chatClient .GetChatThreadClient (threadId );
177174```
178175### Get a thread
179176
@@ -184,9 +181,9 @@ Use `GetChatThread` to retrieve a chat thread from the service.
184181ChatThread chatThread = await chatClient .GetChatThreadAsync (threadId );
185182```
186183
187- ### Get threads (for a member )
184+ ### Get threads (for a participant )
188185
189- Use ` GetChatThreadsInfo ` to get the list of chat threads for the member that instantiated the chatClient.
186+ Use ` GetChatThreadsInfo ` to get the list of chat threads for the participant that instantiated the chatClient.
190187
191188``` C# Snippet:Azure_Communication_Chat_Tests_Samples_GetThreads
192189AsyncPageable < ChatThreadInfo > chatThreadsInfo = chatClient .GetChatThreadsInfoAsync ();
@@ -207,12 +204,12 @@ await chatClient.DeleteChatThreadAsync(threadId);
207204
208205### Update a thread
209206
210- Use ` UpdateChatThread ` to update the chat thread properties .
207+ Use ` UpdateTopic ` to update the chat thread topic .
211208- ` topic ` is used to describe the updated topic for the thread.
212209
213210``` C# Snippet:Azure_Communication_Chat_Tests_Samples_UpdateThread
214211var topic = " new topic" ;
215- await chatThreadClient .UpdateThreadAsync (topic );
212+ await chatThreadClient .UpdateTopicAsync (topic );
216213```
217214
218215## Message Operations
@@ -229,9 +226,9 @@ Use `SendMessage` to send a message to a thread.
229226
230227``` C# Snippet:Azure_Communication_Chat_Tests_Samples_SendMessage
231228var content = " hello world" ;
232- var priority = ChatMessagePriority . Normal ;
229+ var type = ChatMessageType . Html ;
233230var senderDisplayName = " sender name" ;
234- SendChatMessageResult sendMessageResult = await chatThreadClient .SendMessageAsync (content , priority , senderDisplayName );
231+ var messageId = await chatThreadClient .SendMessageAsync (content , type , senderDisplayName );
235232```
236233### Get a message
237234
@@ -251,7 +248,7 @@ Use `GetMessages` to retrieve all messages for the chat thread.
251248AsyncPageable < ChatMessage > allMessages = chatThreadClient .GetMessagesAsync ();
252249await foreach (ChatMessage message in allMessages )
253250{
254- Console .WriteLine ($" {message .Id }:{message .Sender . Id }:{ message . Content }" );
251+ Console .WriteLine ($" {message .Id }:{message .Content }" );
255252}
256253```
257254### Update a message
@@ -272,43 +269,44 @@ Use `DeleteMessage` to delete a message.
272269await chatThreadClient .DeleteMessageAsync (messageId );
273270```
274271
275- ## Thread Member Operations
272+ ## Thread Participant Operations
276273
277- ### Get thread members
274+ ### Get thread participants
278275
279- Use ` GetMembers ` to retrieve the members of the chat thread.
276+ Use ` GetParticipants ` to retrieve the participants of the chat thread.
280277
281- ``` C# Snippet:Azure_Communication_Chat_Tests_Samples_GetMembers
282- AsyncPageable < ChatThreadMember > allMembers = chatThreadClient .GetMembersAsync ();
283- await foreach (ChatThreadMember member in allMembers )
278+ ``` C# Snippet:Azure_Communication_Chat_Tests_Samples_GetParticipants
279+ AsyncPageable < ChatParticipant > allParticipants = chatThreadClient .GetParticipantsAsync ();
280+ await foreach (ChatParticipant participant in allParticipants )
284281{
285- Console .WriteLine ($" {member .User .Id }:{member .DisplayName }:{member .ShareHistoryTime }" );
282+ Console .WriteLine ($" {(( CommunicationUserIdentifier ) participant .User ) .Id }:{participant .DisplayName }:{participant .ShareHistoryTime }" );
286283}
287284```
288- ### Add thread members
285+ ### Add thread participants
289286
290- Use ` AddMembers ` to add members to the chat thread. The following are the supported attributes for each thread member :
291- - ` communicationUser ` , required, it is the identification for the thread member .
292- - ` displayName ` , optional, is the display name for the thread member .
293- - ` shareHistoryTime ` , optional, time from which the chat history is shared with the member .
287+ Use ` AddParticipants ` to add one or more participants to the chat thread. The following are the supported attributes for each thread participant(s) :
288+ - ` communicationUser ` , required, it is the identification for the thread participant .
289+ - ` displayName ` , optional, is the display name for the thread participant .
290+ - ` shareHistoryTime ` , optional, time from which the chat history is shared with the participant .
294291
295- ``` C# Snippet:Azure_Communication_Chat_Tests_Samples_AddMembers
296- var members = new []
292+ ``` C# Snippet:Azure_Communication_Chat_Tests_Samples_AddParticipants
293+ var participants = new []
297294{
298- new ChatThreadMember ( new CommunicationUserIdentifier ( memberId1 )) { DisplayName = " display name member 1 " },
299- new ChatThreadMember ( new CommunicationUserIdentifier ( memberId2 )) { DisplayName = " display name member 2 " },
300- new ChatThreadMember ( new CommunicationUserIdentifier ( memberId3 )) { DisplayName = " display name member 3 " }
295+ new ChatParticipant ( josh ) { DisplayName = " Josh " },
296+ new ChatParticipant ( gloria ) { DisplayName = " Gloria " },
297+ new ChatParticipant ( amy ) { DisplayName = " Amy " }
301298};
302- await chatThreadClient .AddMembersAsync (members );
299+
300+ await chatThreadClient .AddParticipantsAsync (participants );
303301```
304302
305- ### Remove thread member
303+ ### Remove thread participant
306304
307- Use ` RemoveMember ` to remove a thread member from the thread.
308- ` communicationUser ` is the identification of the chat member .
305+ Use ` RemoveParticipant ` to remove a thread participant from the thread.
306+ ` communicationUser ` is the identification of the chat participant .
309307
310- ``` C# Snippet:Azure_Communication_Chat_Tests_Samples_RemoveMember
311- await chatThreadClient .RemoveMemberAsync ( new CommunicationUserIdentifier ( memberId ) );
308+ ``` C# Snippet:Azure_Communication_Chat_Tests_Samples_RemoveParticipant
309+ await chatThreadClient .RemoveParticipantAsync ( gloria );
312310```
313311
314312## Events Operations
@@ -323,21 +321,21 @@ await chatThreadClient.SendTypingNotificationAsync();
323321
324322### Send read receipt
325323
326- Use ` SendReadReceipt ` to notify other members that the message is read by the user.
324+ Use ` SendReadReceipt ` to notify other participants that the message is read by the user.
327325
328326``` C# Snippet:Azure_Communication_Chat_Tests_Samples_SendReadReceipt
329327await chatThreadClient .SendReadReceiptAsync (messageId );
330328```
331329
332330### Get read receipts
333331
334- Use ` GetReadReceipts ` to check the status of messages to see which ones are read by other members of a chat thread.
332+ Use ` GetReadReceipts ` to check the status of messages to see which ones are read by other participants of a chat thread.
335333
336334``` C# Snippet:Azure_Communication_Chat_Tests_Samples_GetReadReceipts
337- AsyncPageable < ReadReceipt > allReadReceipts = chatThreadClient .GetReadReceiptsAsync ();
338- await foreach (ReadReceipt readReceipt in allReadReceipts )
335+ AsyncPageable < ChatMessageReadReceipt > allReadReceipts = chatThreadClient .GetReadReceiptsAsync ();
336+ await foreach (ChatMessageReadReceipt readReceipt in allReadReceipts )
339337{
340- Console .WriteLine ($" {readReceipt .ChatMessageId }:{readReceipt .Sender .Id }:{readReceipt .ReadOn }" );
338+ Console .WriteLine ($" {readReceipt .ChatMessageId }:{(( CommunicationUserIdentifier ) readReceipt .Sender ) .Id }:{readReceipt .ReadOn }" );
341339}
342340```
343341
@@ -347,7 +345,7 @@ A `RequestFailedException` is thrown as a service response for any unsuccessful
347345``` C# Snippet:Azure_Communication_Chat_Tests_Samples_Troubleshooting
348346try
349347{
350- ChatThreadClient chatThreadClient_ = await chatClient .CreateChatThreadAsync (topic : " Hello world!" , members : new [] { chatThreadMember });
348+ CreateChatThreadResult createChatThreadErrorResult = await chatClient .CreateChatThreadAsync (topic : " Hello world!" , participants : new [] { josh });
351349}
352350catch (RequestFailedException ex )
353351{
0 commit comments