Skip to content

Commit 37a6076

Browse files
authored
Merge pull request #204511 from radubulboaca/master
Update `rooms` quick start documentation with public preview updates
2 parents aaab740 + ddb2b60 commit 37a6076

10 files changed

+641
-81
lines changed

articles/communication-services/quickstarts/rooms/get-started-rooms.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
---
2-
title: Quickstart - Create and manage a `room` resource
2+
title: Quickstart - Create and manage a room resource
33
titleSuffix: An Azure Communication Services quickstart
44
description: In this quickstart, you'll learn how to create a Room within your Azure Communication Services resource.
5+
services: azure-communication-services
56
author: radubulboaca
67
manager: mariusu
7-
services: azure-communication-services
88

99
ms.author: radubulboaca
10-
ms.date: 11/19/2021
10+
ms.date: 07/27/2022
1111
ms.topic: quickstart
1212
ms.service: azure-communication-services
1313
ms.custom: mode-other
14-
zone_pivot_groups: acs-csharp-java
14+
zone_pivot_groups: acs-js-csharp-java-python
1515
---
1616
# Quickstart: Create and manage a room resource
1717

18-
[!INCLUDE [Private Preview Disclaimer](../../includes/private-preview-include-section.md)]
18+
[!INCLUDE [Public Preview Notice](../../includes/public-preview-include.md)]
1919

20-
This quickstart will help you get started with Azure Communication Services Rooms. A `room` is a server-managed communications space for a known, fixed set of participants to collaborate for a pre-determined duration. The [rooms conceptual documentation](../../concepts/rooms/room-concept.md) covers more details and potential use cases for `rooms`.
20+
This quickstart will help you get started with Azure Communication Services Rooms. A `room` is a server-managed communications space for a known, fixed set of participants to collaborate for a pre-determined duration. The [rooms conceptual documentation](../../concepts/rooms/room-concept.md) covers more details and use cases for `rooms`.
21+
22+
::: zone pivot="programming-language-javascript"
23+
[!INCLUDE [Use rooms with Java SDK](./includes/rooms-quickstart-javascript.md)]
24+
::: zone-end
2125

2226
::: zone pivot="programming-language-csharp"
2327
[!INCLUDE [Use rooms with .NET SDK](./includes/rooms-quickstart-net.md)]
@@ -27,25 +31,31 @@ This quickstart will help you get started with Azure Communication Services Room
2731
[!INCLUDE [Use rooms with Java SDK](./includes/rooms-quickstart-java.md)]
2832
::: zone-end
2933

34+
::: zone pivot="programming-language-python"
35+
[!INCLUDE [Use rooms with Java SDK](./includes/rooms-quickstart-python.md)]
36+
::: zone-end
37+
3038
## Object model
3139

3240
The table below lists the main properties of `room` objects:
3341

3442
| Name | Description |
3543
|-----------------------|-------------------------------------------|
3644
| `roomId` | Unique `room` identifier. |
37-
| `ValidFrom` | Earliest time a `room` can be used. |
38-
| `ValidUntil` | Latest time a `room` can be used. |
39-
| `Participants` | List of pre-existing participant IDs. |
45+
| `validFrom` | Earliest time a `room` can be used. |
46+
| `validUntil` | Latest time a `room` can be used. |
47+
| `roomJoinPolicy` | Specifies which user identities are allowed to join room calls. Valid options are `InviteOnly` and `CommunicationServiceUsers`. |
48+
| `participants` | List of participants to a `room`. Specified as a `CommunicationIdentifier`. |
4049

4150
## Next steps
4251

52+
Once you've created the room and configured it, you can learn how to [join a rooms call](join-rooms-call.md).
53+
4354
In this section you learned how to:
4455
> [!div class="checklist"]
4556
> - Create a new room
4657
> - Get the properties of a room
4758
> - Update the properties of a room
48-
> - Join a room call
4959
> - Delete a room
5060
5161
You may also want to:
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: azure-communication-services
5+
author: radubulboaca
6+
manager: mariusu
7+
8+
ms.service: azure-communication-services
9+
ms.date: 07/13/2022
10+
ms.topic: include
11+
ms.custom: include file
12+
ms.author: radubulboaca
13+
---
14+
15+
## Join a room call
16+
17+
To join a room call, set up your web application using the [Add video calling to your client app](../../voice-video-calling/get-started-with-video-calling.md?pivots=platform-android) guide. Alternatively, you can download the video calling quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-android-quickstarts/tree/main/videoCallingQuickstart).
18+
19+
Create a `CallAgent` with a valid user token:
20+
21+
```Java
22+
private fun createAgent() {
23+
val userToken: String = checkNotNull(null){"userToken must be set"}
24+
25+
try {
26+
val credential = CommunicationTokenCredential(userToken)
27+
val callClient = CallClient()
28+
callAgent = callClient.createCallAgent(applicationContext, credential).get()
29+
} catch (ex: Exception) {
30+
Toast.makeText(applicationContext, "Failed to create call agent.", Toast.LENGTH_SHORT).show()
31+
}
32+
}
33+
```
34+
35+
Use the `CallAgent` and `RoomCallLocator` to join a room call, the `CallAgent.join` method will return a `Call` object:
36+
37+
```Java
38+
val roomCallLocator = RoomCallLocator(roomId)
39+
call = callAgent.join(applicationContext, roomCallLocator, joinCallOptions)
40+
```
41+
42+
Subscribe to `Call` events to get updates:
43+
44+
```Java
45+
call.addOnRemoteParticipantsUpdatedListener { args: ParticipantsUpdatedEvent? ->
46+
handleRemoteParticipantsUpdate(
47+
args!!
48+
)
49+
}
50+
51+
call.addOnStateChangedListener { args: PropertyChangedEvent? ->
52+
this.handleCallOnStateChanged(
53+
args!!
54+
)
55+
}
56+
```
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: azure-communication-services
5+
author: radubulboaca
6+
manager: mariusu
7+
8+
ms.service: azure-communication-services
9+
ms.date: 07/13/2022
10+
ms.topic: include
11+
ms.custom: include file
12+
ms.author: radubulboaca
13+
---
14+
15+
16+
## Join a room call
17+
18+
To join a room call, set up your web application using the [Add video calling to your client app](../../voice-video-calling/get-started-with-video-calling.md?pivots=platform-ios) guide. Alternatively, you can download the video calling quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-ios-quickstarts/tree/main/Add%20Video%20Calling).
19+
20+
You'll need a User Access Token when initializing a CallAgent instance to join room calls. Once you have a token, Add the following code to the `onAppear` callback in `ContentView.swift`. You'll need to replace `<USER ACCESS TOKEN>` with a valid user access token for your resource:
21+
22+
```Swift
23+
var userCredential: CommunicationTokenCredential?
24+
do {
25+
userCredential = try CommunicationTokenCredential(token: "<USER ACCESS TOKEN>")
26+
} catch {
27+
print("ERROR: It was not possible to create user credential.")
28+
return
29+
}
30+
```
31+
32+
To create a CallAgent instance from a CallClient, use the `callClient.createCallAgent` method that asynchronously returns a CallAgent object once it's initialized. DeviceManager lets you enumerate local devices that can be used in a call to transmit audio/video streams. It also allows you to request permission from a user to access microphone/camera.
33+
34+
```Swift
35+
self.callClient = CallClient()
36+
self.callClient?.createCallAgent(userCredential: userCredential!) { (agent, error) in
37+
if error != nil {
38+
print("ERROR: It was not possible to create a call agent.")
39+
return
40+
} else {
41+
self.callAgent = agent
42+
print("Call agent successfully created.")
43+
self.callAgent!.delegate = callHandler
44+
self.callClient?.getDeviceManager { (deviceManager, error) in
45+
if (error == nil) {
46+
print("Got device manager instance")
47+
self.deviceManager = deviceManager
48+
} else {
49+
print("Failed to get device manager instance")
50+
}
51+
}
52+
}
53+
}
54+
```
55+
56+
The `joinRoomCall` method is set as the action that will be performed when the Join Room Call button is tapped.
57+
58+
```Swift
59+
func joinRoomCall() {
60+
if self.callAgent == nil {
61+
print("CallAgent not initialized")
62+
return
63+
}
64+
65+
if (self.roomId.isEmpty) {
66+
print("Room ID not set")
67+
return
68+
}
69+
70+
// Join a call with a Room ID
71+
let options = JoinCallOptions()
72+
let audioOptions = AudioOptions()
73+
audioOptions.muted = self.muted
74+
75+
options.audioOptions = audioOptions
76+
77+
let roomCallLocator = RoomCallLocator(roomId: roomId)
78+
self.callAgent!.join(with: roomCallLocator, joinCallOptions: options) { (call, error) in
79+
self.setCallAndObserver(call: call, error: error)
80+
}
81+
}
82+
```
83+
84+
`CallObserver` is used to manage mid-call events and remote participants. We'll set the observers in the `setCallAndOberserver` function.
85+
86+
```Swift
87+
func setCallAndObserver(call:Call!, error:Error?) {
88+
if (error == nil) {
89+
self.call = call
90+
self.callObserver = CallObserver(view:self)
91+
92+
self.call!.delegate = self.callObserver
93+
94+
if (self.call!.state == CallState.connected) {
95+
self.callObserver!.handleInitialCallState(call: call)
96+
}
97+
} else {
98+
print("Failed to get call object")
99+
}
100+
}
101+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: azure-communication-services
5+
author: radubulboaca
6+
manager: mariusu
7+
8+
ms.service: azure-communication-services
9+
ms.date: 07/13/2022
10+
ms.topic: include
11+
ms.custom: include file
12+
ms.author: radubulboaca
13+
---
14+
15+
## Join a room call
16+
17+
To join a room call, set up your web application using the [Add video calling to your client app](../../voice-video-calling/get-started-with-video-calling.md?pivots=platform-web) guide. Alternatively, you can download the video calling quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/add-1-on-1-video-calling).
18+
19+
Once you have an initialized and authenticated `callAgent`, you may specify a context object with the `roomId` property as the `room` identifier. To join the call, use the `join` method and pass the context instance.
20+
21+
```js
22+
23+
const context = { roomId: '<RoomId>' }
24+
25+
const call = callAgent.join(context);
26+
27+
```

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

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ mvn archetype:generate -DgroupId=com.contoso.app -DartifactId=rooms-quickstart -
3232
```
3333

3434
### Include the package
35+
3536
#### Include the BOM file
3637

3738
Include the `azure-sdk-bom` to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.
@@ -88,9 +89,17 @@ RoomsClient roomsClient = new RoomsClientBuilder().connectionString(connectionSt
8889
Create a new `room` with default properties using the code snippet below:
8990

9091
```java
91-
RoomRequest request = new RoomRequest();
92-
CommunicationRoom createCommunicationRoom = roomsClient.createRoom(request);
93-
String roomId = createCommunicationRoom.getRoomId()
92+
OffsetDateTime validFrom = OffsetDateTime.of(2022, 8, 1, 5, 30, 20, 10, ZoneOffset.UTC);
93+
OffsetDateTime validUntil = OffsetDateTime.of(2022, 9, 1, 5, 30, 20, 10, ZoneOffset.UTC);
94+
List<RoomParticipant> participants = new ArrayList<>();
95+
96+
// Add participants
97+
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(RoleType.ATTENDEE));
98+
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(RoleType.CONSUMER));
99+
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 3>")).setRole(RoleType.ATTENDEE));
100+
101+
RoomsClient roomsClient = createRoomsClientWithConnectionString();
102+
CommunicationRoom roomResult = roomsClient.createRoom(validFrom, validUntil, RoomJoinPolicy.INVITE_ONLY, participants);
94103
```
95104

96105
Since `rooms` are server-side entities, you may want to keep track of and persist the `roomId` in the storage medium of choice. You can reference the `roomId` to view or update the properties of a `room` object.
@@ -120,48 +129,43 @@ CommunicationRoom roomResult = roomsClient.updateRoom(roomId, request);
120129

121130
### Add new participants
122131

123-
To add new participants to a `room`, issue an update request on the room's `Participants`:
132+
To add new participants to a `room`, use the `addParticipants` method exposed on the client.
124133

125134
```java
126-
Map<String, Object> participants = new HashMap<>();
127-
participants.put("<CommunicationUserIdentifier.Id1>", new RoomParticipant());
128-
participants.put("<CommunicationUserIdentifier.Id2>", new RoomParticipant());
129-
participants.put("<CommunicationUserIdentifier.Id3>", new RoomParticipant());
130-
131-
RoomRequest request = new RoomRequest();
132-
request.setParticipants(participants);
133-
134-
CommunicationRoom roomResult = roomsClient.updateRoom(roomId, request);
135+
RoomParticipant user1 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(RoleType.ATTENDEE);
136+
RoomParticipant user2 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(RoleType.PRESENTER);
137+
RoomParticipant user3 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 3>")).setRole(RoleType.CONSUMER);
138+
139+
List<RoomParticipant> participants = new ArrayList<RoomParticipant>(Arrays.asList(user1, user2, user3));
140+
RoomsClient roomsClient = createRoomsClientWithConnectionString();
141+
142+
try {
143+
ParticipantsCollection roomParticipants = roomsClient.addParticipants("<Room Id>", participants);
144+
System.out.println("No. of Participants in Room: " + roomParticipants.getParticipants().size());
145+
} catch (RuntimeException ex) {
146+
System.out.println(ex);
147+
}
135148
```
136149

137150
Participants that have been added to a `room` become eligible to join calls.
138151

139152
### Remove participants
140153

141-
To remove a participant from a `room` and revoke their access, update the `Participants` list:
154+
To remove a participant from a `room` and revoke their access, use the `removeParticipants` method.
142155

143156
```java
144-
Map<String, Object> participants = new HashMap<>();
145-
participants.put("<CommunicationUserIdentifier.Id1>", null);
146-
participants.put("<CommunicationUserIdentifier.Id2>", null);
147-
participants.put("<CommunicationUserIdentifier.Id3>", null);
148-
149-
RoomRequest request = new RoomRequest();
150-
request.setParticipants(participants);
151-
152-
CommunicationRoom roomResult = roomsClient.updateRoom(roomId, request);
153-
```
154-
155-
### Join a room call
156-
157-
To join a room call, set up your web application using the [Add voice calling to your client app](../../voice-video-calling/getting-started-with-calling.md) guide. Once you have an initialized and authenticated `callAgent`, you may specify a context object with the `roomId` property as the `room` identifier. To join the call, use the `join` method and pass the context instance.
158-
159-
```js
160-
161-
const context = { roomId: '<RoomId>' }
162-
163-
const call = callAgent.join(context);
164-
157+
RoomParticipant user1 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(RoleType.ATTENDEE);
158+
RoomParticipant user2 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(RoleType.PRESENTER);
159+
160+
List<RoomParticipant> participants = new ArrayList<RoomParticipant>(Arrays.asList(user1, user2));
161+
RoomsClient roomsClient = createRoomsClientWithConnectionString();
162+
163+
try {
164+
ParticipantsCollection roomParticipants = roomsClient.removeParticipants("<Room Id>", participants);
165+
System.out.println("Room Id: " + roomParticipants.getParticipants().size());
166+
} catch (RuntimeException ex) {
167+
System.out.println(ex);
168+
}
165169
```
166170

167171
### Delete room

0 commit comments

Comments
 (0)