Skip to content

Commit faf0204

Browse files
PR for Server Calling SDK Public Preview (Azure#22282)
* first commit * apply new name changes (Azure#22298) * name changes and refactoring * name changes and refactoring * fix(test): increase branch coverage, change groupId generation * fix(*): remove test connection string * fix(test): raise branch coverage * apiview review fix (Azure#22304) * live test fixes (Azure#22312) * fix links (Azure#22318) * skip test refactor (Azure#22324) * skip test refactor (Azure#22327) * skip test refactor (Azure#22328) Co-authored-by: Christian Whitehead <chrwhit@microsoft.com>
1 parent aeeb98e commit faf0204

File tree

81 files changed

+1767
-1468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1767
-1468
lines changed

sdk/communication/azure-communication-callingserver/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ This is a Public Preview version, so breaking changes are possible in subsequent
1111
- Play audio in the call.
1212
- Outbound APIs for call recording including start, pause, resume and stop.
1313
- Subscribe to tone and receive tone selections via events.
14-
- Invite and remove participants from the call.
14+
- Add and remove participants from the call.
1515

1616
<!-- LINKS -->
17-
[read_me]: https://github.com/Azure/azure-sdk-for-java/blob/feature/communication-ServerCalling/sdk/communication/azure-communication-callingserver/README.md
17+
[read_me]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/communication/azure-communication-callingserver/README.md
1818

1919

sdk/communication/azure-communication-callingserver/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee,
7070

7171
String callbackUri = "<callback-uri-for-notification>";
7272

73-
CallModality[] requestedMediaTypes = new CallModality[] { CallModality.AUDIO, CallModality.VIDEO };
73+
MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO };
7474

7575
EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] {
76-
EventSubscriptionType.DTMF_RECEIVED,
77-
EventSubscriptionType.PARTICIPANTS_UPDATED };
76+
EventSubscriptionType.DTMF_RECEIVED,
77+
EventSubscriptionType.PARTICIPANTS_UPDATED
78+
};
7879

7980
CreateCallOptions createCallOptions = new CreateCallOptions(
8081
callbackUri,
@@ -173,4 +174,4 @@ Check out other client libraries for Azure Communication Services
173174
[product_docs]: https://docs.microsoft.com/azure/communication-services/
174175
[package]: https://search.maven.org/artifact/com.azure/azure-communication-callingserver
175176
[api_documentation]: https://aka.ms/java-docs
176-
[source]: https://github.com/Azure/azure-sdk-for-java/tree/feature/communication-ServerCalling/sdk/communication/azure-communication-callingserver/src
177+
[source]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/communication/azure-communication-callingserver/src

sdk/communication/azure-communication-callingserver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<test.dir>src/test</test.dir>
4343
<jacoco.min.linecoverage>0.70</jacoco.min.linecoverage>
4444
<jacoco.min.branchcoverage>0.70</jacoco.min.branchcoverage>
45-
<jacoco.skip.coverage.check>true</jacoco.skip.coverage.check>
45+
<jacoco.skip.coverage.check>false</jacoco.skip.coverage.check>
4646
</properties>
4747

4848
<dependencies>

sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package com.azure.communication.callingserver;
55

6+
import com.azure.communication.callingserver.models.AddParticipantResult;
67
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
78
import com.azure.communication.callingserver.models.PlayAudioOptions;
89
import com.azure.communication.callingserver.models.PlayAudioResult;
@@ -92,7 +93,7 @@ public Response<PlayAudioResult> playAudioWithResponse(
9293
String audioFileId,
9394
String callbackUri,
9495
String operationContext,
95-
Context context) {
96+
final Context context) {
9697
return callConnectionAsync
9798
.playAudioWithResponseInternal(
9899
audioFileUri,
@@ -118,20 +119,18 @@ public Response<PlayAudioResult> playAudioWithResponse(
118119
public Response<PlayAudioResult> playAudioWithResponse(
119120
String audioFileUri,
120121
PlayAudioOptions playAudioOptions,
121-
Context context) {
122+
final Context context) {
122123
return callConnectionAsync
123124
.playAudioWithResponseInternal(audioFileUri, playAudioOptions, context)
124125
.block();
125126
}
126127

127128
/**
128129
* Disconnect the current caller in a group-call or end a p2p-call.
129-
*
130-
* @return response for a successful hangup request.
131130
*/
132131
@ServiceMethod(returns = ReturnType.SINGLE)
133-
public Void hangup() {
134-
return callConnectionAsync.hangup().block();
132+
public void hangup() {
133+
callConnectionAsync.hangup().block();
135134
}
136135

137136
/**
@@ -141,7 +140,7 @@ public Void hangup() {
141140
* @return response for a successful hangup request.
142141
*/
143142
@ServiceMethod(returns = ReturnType.SINGLE)
144-
public Response<Void> hangupWithResponse(Context context) {
143+
public Response<Void> hangupWithResponse(final Context context) {
145144
return callConnectionAsync.hangupWithResponse(context).block();
146145
}
147146

@@ -168,21 +167,21 @@ public CancelAllMediaOperationsResult cancelAllMediaOperations(String operationC
168167
@ServiceMethod(returns = ReturnType.SINGLE)
169168
public Response<CancelAllMediaOperationsResult> cancelAllMediaOperationsWithResponse(
170169
String operationContext,
171-
Context context) {
170+
final Context context) {
172171
return callConnectionAsync.cancelAllMediaOperationsWithResponse(operationContext, context).block();
173172
}
174173

175174
/**
176175
* Add a participant to the call.
177176
*
178-
* @param participant Invited participant.
177+
* @param participant Added participant.
179178
* @param alternateCallerId The phone number to use when adding a phone number participant.
180179
* @param operationContext The value to identify context of the operation. This is used to co-relate other
181180
* communications related to this operation
182181
* @return response for a successful add participant request.
183182
*/
184183
@ServiceMethod(returns = ReturnType.SINGLE)
185-
public Void addParticipant(
184+
public AddParticipantResult addParticipant(
186185
CommunicationIdentifier participant,
187186
String alternateCallerId,
188187
String operationContext) {
@@ -192,19 +191,19 @@ public Void addParticipant(
192191
/**
193192
* Add a participant to the call.
194193
*
195-
* @param participant Invited participant.
194+
* @param participant Added participant.
196195
* @param alternateCallerId The phone number to use when adding a phone number participant.
197196
* @param operationContext The value to identify context of the operation. This is used to co-relate other
198197
* communications related to this operation
199198
* @param context A {@link Context} representing the request context.
200199
* @return response for a successful add participant request.
201200
*/
202201
@ServiceMethod(returns = ReturnType.SINGLE)
203-
public Response<Void> addParticipantWithResponse(
202+
public Response<AddParticipantResult> addParticipantWithResponse(
204203
CommunicationIdentifier participant,
205204
String alternateCallerId,
206205
String operationContext,
207-
Context context) {
206+
final Context context) {
208207
return callConnectionAsync
209208
.addParticipantWithResponse(participant, alternateCallerId, operationContext, context).block();
210209
}
@@ -213,11 +212,10 @@ public Response<Void> addParticipantWithResponse(
213212
* Remove a participant from the call.
214213
*
215214
* @param participantId Participant id.
216-
* @return response for a successful remove participant request.
217215
*/
218216
@ServiceMethod(returns = ReturnType.SINGLE)
219-
public Void removeParticipant(String participantId) {
220-
return callConnectionAsync.removeParticipant(participantId).block();
217+
public void removeParticipant(String participantId) {
218+
callConnectionAsync.removeParticipant(participantId).block();
221219
}
222220

223221
/**
@@ -228,7 +226,7 @@ public Void removeParticipant(String participantId) {
228226
* @return response for a successful remove participant request.
229227
*/
230228
@ServiceMethod(returns = ReturnType.SINGLE)
231-
public Response<Void> removeParticipantWithResponse(String participantId, Context context) {
229+
public Response<Void> removeParticipantWithResponse(String participantId, final Context context) {
232230
return callConnectionAsync.removeParticipantWithResponse(participantId, context).block();
233231
}
234232
}

sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33

44
package com.azure.communication.callingserver;
55

6-
import static com.azure.core.util.FluxUtil.monoError;
7-
import static com.azure.core.util.FluxUtil.withContext;
8-
9-
import java.util.Objects;
10-
116
import com.azure.communication.callingserver.implementation.CallConnectionsImpl;
12-
import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
13-
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
147
import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
8+
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
9+
import com.azure.communication.callingserver.implementation.converters.AddParticipantRequestConverter;
1510
import com.azure.communication.callingserver.implementation.converters.PlayAudioResultConverter;
16-
import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
11+
import com.azure.communication.callingserver.implementation.models.AddParticipantRequest;
1712
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
18-
import com.azure.communication.callingserver.implementation.models.InviteParticipantsRequest;
13+
import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException;
1914
import com.azure.communication.callingserver.implementation.models.PlayAudioRequest;
15+
import com.azure.communication.callingserver.models.AddParticipantResult;
2016
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
2117
import com.azure.communication.callingserver.models.PlayAudioOptions;
2218
import com.azure.communication.callingserver.models.PlayAudioResult;
@@ -27,9 +23,13 @@
2723
import com.azure.core.http.rest.SimpleResponse;
2824
import com.azure.core.util.Context;
2925
import com.azure.core.util.logging.ClientLogger;
30-
3126
import reactor.core.publisher.Mono;
3227

28+
import java.util.Objects;
29+
30+
import static com.azure.core.util.FluxUtil.monoError;
31+
import static com.azure.core.util.FluxUtil.withContext;
32+
3333
/**
3434
* Async client that supports call connection operations.
3535
*/
@@ -132,7 +132,7 @@ Mono<PlayAudioResult> playAudioInternal(String audioFileUri, PlayAudioOptions pl
132132
Mono<PlayAudioResult> playAudioInternal(PlayAudioRequest playAudioRequest) {
133133
try {
134134
return callConnectionInternal.playAudioAsync(callConnectionId, playAudioRequest)
135-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
135+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
136136
.flatMap(result -> Mono.just(PlayAudioResultConverter.convert(result)));
137137
} catch (RuntimeException ex) {
138138
return monoError(logger, ex);
@@ -236,7 +236,7 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
236236
contextValue = context == null ? contextValue : context;
237237
return callConnectionInternal
238238
.playAudioWithResponseAsync(callConnectionId, playAudioRequest, contextValue)
239-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
239+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
240240
.map(response ->
241241
new SimpleResponse<>(response, PlayAudioResultConverter.convert(response.getValue())));
242242
});
@@ -254,7 +254,8 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
254254
public Mono<Void> hangup() {
255255
try {
256256
return callConnectionInternal.hangupCallAsync(callConnectionId)
257-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
257+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
258+
.flatMap(result -> Mono.empty());
258259
} catch (RuntimeException ex) {
259260
return monoError(logger, ex);
260261
}
@@ -275,7 +276,7 @@ Mono<Response<Void>> hangupWithResponse(Context context) {
275276
return withContext(contextValue -> {
276277
contextValue = context == null ? contextValue : context;
277278
return callConnectionInternal.hangupCallWithResponseAsync(callConnectionId, contextValue)
278-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
279+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
279280
});
280281
} catch (RuntimeException ex) {
281282
return monoError(logger, ex);
@@ -295,7 +296,7 @@ public Mono<CancelAllMediaOperationsResult> cancelAllMediaOperations(String oper
295296
CancelAllMediaOperationsRequest request = new CancelAllMediaOperationsRequest();
296297
request.setOperationContext(operationContext);
297298
return callConnectionInternal.cancelAllMediaOperationsAsync(callConnectionId, request)
298-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
299+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
299300
.flatMap(result -> Mono.just(CancelAllMediaOperationsResultConverter.convert(result)));
300301
} catch (RuntimeException ex) {
301302
return monoError(logger, ex);
@@ -324,7 +325,7 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
324325
contextValue = context == null ? contextValue : context;
325326
return callConnectionInternal
326327
.cancelAllMediaOperationsWithResponseAsync(callConnectionId, request, contextValue)
327-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
328+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
328329
.map(response ->
329330
new SimpleResponse<>(response, CancelAllMediaOperationsResultConverter.convert(response.getValue())));
330331
});
@@ -336,25 +337,26 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
336337
/**
337338
* Add a participant to the call.
338339
*
339-
* @param participant Invited participant.
340+
* @param participant Added participant.
340341
* @param alternateCallerId The phone number to use when adding a phone number participant.
341342
* @param operationContext The value to identify context of the operation. This is used to co-relate other
342343
* communications related to this operation
343344
* @return response for a successful add participant request.
344345
*/
345346
@ServiceMethod(returns = ReturnType.SINGLE)
346-
public Mono<Void> addParticipant(
347+
public Mono<AddParticipantResult> addParticipant(
347348
CommunicationIdentifier participant,
348349
String alternateCallerId,
349350
String operationContext) {
350351
try {
351352
Objects.requireNonNull(participant, "'participant' cannot be null.");
352-
InviteParticipantsRequest request = InviteParticipantRequestConverter.convert(participant,
353+
AddParticipantRequest request = AddParticipantRequestConverter.convert(participant,
353354
alternateCallerId,
354355
operationContext,
355356
null);
356-
return callConnectionInternal.inviteParticipantsAsync(callConnectionId, request)
357-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
357+
return callConnectionInternal.addParticipantAsync(callConnectionId, request)
358+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
359+
.flatMap(result -> Mono.just(new AddParticipantResult(result.getParticipantId())));
358360
} catch (RuntimeException ex) {
359361
return monoError(logger, ex);
360362
}
@@ -363,35 +365,37 @@ public Mono<Void> addParticipant(
363365
/**
364366
* Add a participant to the call.
365367
*
366-
* @param participant Invited participant.
368+
* @param participant Added participant.
367369
* @param alternateCallerId The phone number to use when adding a phone number participant.
368370
* @param operationContext The value to identify context of the operation. This is used to co-relate other
369371
* communications related to this operation
370372
* @return response for a successful add participant request.
371373
*/
372374
@ServiceMethod(returns = ReturnType.SINGLE)
373-
public Mono<Response<Void>> addParticipantWithResponse(
375+
public Mono<Response<AddParticipantResult>> addParticipantWithResponse(
374376
CommunicationIdentifier participant,
375377
String alternateCallerId,
376378
String operationContext) {
377379
return addParticipantWithResponse(participant, alternateCallerId, operationContext, null);
378380
}
379381

380-
Mono<Response<Void>> addParticipantWithResponse(
382+
Mono<Response<AddParticipantResult>> addParticipantWithResponse(
381383
CommunicationIdentifier participant,
382384
String alternateCallerId,
383385
String operationContext,
384386
Context context) {
385387
try {
386388
Objects.requireNonNull(participant, "'participant' cannot be null.");
387-
InviteParticipantsRequest request =
388-
InviteParticipantRequestConverter
389+
AddParticipantRequest request =
390+
AddParticipantRequestConverter
389391
.convert(participant, alternateCallerId, operationContext, null);
390392
return withContext(contextValue -> {
391393
contextValue = context == null ? contextValue : context;
392394
return callConnectionInternal
393-
.inviteParticipantsWithResponseAsync(callConnectionId, request, contextValue)
394-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
395+
.addParticipantWithResponseAsync(callConnectionId, request, contextValue)
396+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
397+
.map(response ->
398+
new SimpleResponse<>(response, new AddParticipantResult(response.getValue().getParticipantId())));
395399
});
396400
} catch (RuntimeException ex) {
397401
return monoError(logger, ex);
@@ -408,7 +412,8 @@ Mono<Response<Void>> addParticipantWithResponse(
408412
public Mono<Void> removeParticipant(String participantId) {
409413
try {
410414
return callConnectionInternal.removeParticipantAsync(callConnectionId, participantId)
411-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
415+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
416+
.flatMap(result -> Mono.empty());
412417
} catch (RuntimeException ex) {
413418
return monoError(logger, ex);
414419
}
@@ -431,7 +436,7 @@ Mono<Response<Void>> removeParticipantWithResponse(String participantId, Context
431436
contextValue = context == null ? contextValue : context;
432437
return callConnectionInternal
433438
.removeParticipantWithResponseAsync(callConnectionId, participantId, contextValue)
434-
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
439+
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
435440
});
436441
} catch (RuntimeException ex) {
437442
return monoError(logger, ex);

0 commit comments

Comments
 (0)