Skip to content

Commit 847bf5d

Browse files
author
Minnie Liu
committed
Add subsection for creating room participants
1 parent eceda04 commit 847bf5d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

articles/communication-services/quickstarts/rooms/includes/rooms-quickstart-net.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,37 +86,45 @@ Create a new `RoomsClient` object that will be used to create new `rooms` and ma
8686
var connectionString = "<connection_string>";
8787
RoomsClient roomsClient = new RoomsClient(connectionString);
8888

89-
// Create identities for users
90-
CommunicationIdentityClient identityClient = new CommunicationIdentityClient(connectionString);
91-
CommunicationUserIdentifier user1 = await identityClient.CreateUser();
92-
CommunicationUserIdentifier user2 = await identityClient.CreateUser();
93-
9489
```
9590

9691
## Create a room
9792

98-
Create a new `room` with default properties using the code snippet below:
93+
### Set up room participants
94+
In order to set up room participants, you'll need to initialize a `CommunicationIdentityClient` to create the communication user identities who will be granted access to join the room.
9995

10096
```csharp
10197

102-
// Create a room
103-
List roomParticipants = new List<RoomParticipant>();
104-
roomParticipants.Add(new RoomParticipant(new CommunicationUserIdentifier(user1.Value.User.Id), RoleType.Presenter));
98+
// Create identities for users who will join the room
99+
CommunicationIdentityClient identityClient = new CommunicationIdentityClient(connectionString);
100+
CommunicationUserIdentifier user1 = await identityClient.CreateUser();
101+
CommunicationUserIdentifier user2 = await identityClient.CreateUser();
102+
```
105103

104+
Alternatively, you can follow the instructions [here](https://learn.microsoft.com/azure/communication-services/quickstarts/rooms/join-rooms-call?pivots=platform-web#obtain-user-access-token) to create a user and access token.
106105

106+
After the user identities have been created, you can create a `RoomParticipant` and assign a role. If a role is not assigned, then the participant will be assigned `Attendee` role by default.
107+
```csharp
107108
RoomParticipant participant1 = new RoomParticipant(user1) { Role = ParticipantRole.Presenter };
108109
RoomParticipant participant2 = new RoomParticipant(user2) { Role = ParticipantRole.Attendee };
109110

110111
List<RoomParticipant> participants = new List<RoomParticipant>();
111112

112113
participants.Add(participant1);
113114
participants.Add(participant2);
115+
```
116+
117+
### Initialize the room
118+
Create a new `room` with default properties using the code snippet below:
119+
120+
```csharp
114121

122+
// Create a room
115123
DateTimeOffset validFrom = DateTimeOffset.UtcNow;
116124
DateTimeOffset validUntil = validFrom.AddDays(1);
117125
CancellationToken cancellationToken = new CancellationTokenSource().Token;
118126

119-
CommunicationRoom createdRoom = await roomsClient.CreateRoomAsync(validFrom, validUntil, roomParticipants, cancellationToken);
127+
CommunicationRoom createdRoom = await roomsClient.CreateRoomAsync(validFrom, validUntil, participants, cancellationToken);
120128
string roomId = createdRoom.Id;
121129
Console.WriteLine("\nCreated room with id: " + roomId);
122130

0 commit comments

Comments
 (0)