Skip to content

Commit

Permalink
PR for Server Calling SDK Public Preview (#22282)
Browse files Browse the repository at this point in the history
* first commit

* apply new name changes (#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 (#22304)

* live test fixes (#22312)

* fix links (#22318)

* skip test refactor (#22324)

* skip test refactor (#22327)

* skip test refactor (#22328)

Co-authored-by: Christian Whitehead <[email protected]>
  • Loading branch information
arifsaikat-microsoft and chrwhit authored Jun 16, 2021
1 parent aeeb98e commit faf0204
Show file tree
Hide file tree
Showing 81 changed files with 1,767 additions and 1,468 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This is a Public Preview version, so breaking changes are possible in subsequent
- Play audio in the call.
- Outbound APIs for call recording including start, pause, resume and stop.
- Subscribe to tone and receive tone selections via events.
- Invite and remove participants from the call.
- Add and remove participants from the call.

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


9 changes: 5 additions & 4 deletions sdk/communication/azure-communication-callingserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee,

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

CallModality[] requestedMediaTypes = new CallModality[] { CallModality.AUDIO, CallModality.VIDEO };
MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO };

EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] {
EventSubscriptionType.DTMF_RECEIVED,
EventSubscriptionType.PARTICIPANTS_UPDATED };
EventSubscriptionType.DTMF_RECEIVED,
EventSubscriptionType.PARTICIPANTS_UPDATED
};

CreateCallOptions createCallOptions = new CreateCallOptions(
callbackUri,
Expand Down Expand Up @@ -173,4 +174,4 @@ Check out other client libraries for Azure Communication Services
[product_docs]: https://docs.microsoft.com/azure/communication-services/
[package]: https://search.maven.org/artifact/com.azure/azure-communication-callingserver
[api_documentation]: https://aka.ms/java-docs
[source]: https://github.com/Azure/azure-sdk-for-java/tree/feature/communication-ServerCalling/sdk/communication/azure-communication-callingserver/src
[source]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/communication/azure-communication-callingserver/src
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<test.dir>src/test</test.dir>
<jacoco.min.linecoverage>0.70</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.70</jacoco.min.branchcoverage>
<jacoco.skip.coverage.check>true</jacoco.skip.coverage.check>
<jacoco.skip.coverage.check>false</jacoco.skip.coverage.check>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.communication.callingserver;

import com.azure.communication.callingserver.models.AddParticipantResult;
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
import com.azure.communication.callingserver.models.PlayAudioOptions;
import com.azure.communication.callingserver.models.PlayAudioResult;
Expand Down Expand Up @@ -92,7 +93,7 @@ public Response<PlayAudioResult> playAudioWithResponse(
String audioFileId,
String callbackUri,
String operationContext,
Context context) {
final Context context) {
return callConnectionAsync
.playAudioWithResponseInternal(
audioFileUri,
Expand All @@ -118,20 +119,18 @@ public Response<PlayAudioResult> playAudioWithResponse(
public Response<PlayAudioResult> playAudioWithResponse(
String audioFileUri,
PlayAudioOptions playAudioOptions,
Context context) {
final Context context) {
return callConnectionAsync
.playAudioWithResponseInternal(audioFileUri, playAudioOptions, context)
.block();
}

/**
* Disconnect the current caller in a group-call or end a p2p-call.
*
* @return response for a successful hangup request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Void hangup() {
return callConnectionAsync.hangup().block();
public void hangup() {
callConnectionAsync.hangup().block();
}

/**
Expand All @@ -141,7 +140,7 @@ public Void hangup() {
* @return response for a successful hangup request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> hangupWithResponse(Context context) {
public Response<Void> hangupWithResponse(final Context context) {
return callConnectionAsync.hangupWithResponse(context).block();
}

Expand All @@ -168,21 +167,21 @@ public CancelAllMediaOperationsResult cancelAllMediaOperations(String operationC
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CancelAllMediaOperationsResult> cancelAllMediaOperationsWithResponse(
String operationContext,
Context context) {
final Context context) {
return callConnectionAsync.cancelAllMediaOperationsWithResponse(operationContext, context).block();
}

/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Void addParticipant(
public AddParticipantResult addParticipant(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext) {
Expand All @@ -192,19 +191,19 @@ public Void addParticipant(
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @param context A {@link Context} representing the request context.
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> addParticipantWithResponse(
public Response<AddParticipantResult> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
Context context) {
final Context context) {
return callConnectionAsync
.addParticipantWithResponse(participant, alternateCallerId, operationContext, context).block();
}
Expand All @@ -213,11 +212,10 @@ public Response<Void> addParticipantWithResponse(
* Remove a participant from the call.
*
* @param participantId Participant id.
* @return response for a successful remove participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Void removeParticipant(String participantId) {
return callConnectionAsync.removeParticipant(participantId).block();
public void removeParticipant(String participantId) {
callConnectionAsync.removeParticipant(participantId).block();
}

/**
Expand All @@ -228,7 +226,7 @@ public Void removeParticipant(String participantId) {
* @return response for a successful remove participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> removeParticipantWithResponse(String participantId, Context context) {
public Response<Void> removeParticipantWithResponse(String participantId, final Context context) {
return callConnectionAsync.removeParticipantWithResponse(participantId, context).block();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@

package com.azure.communication.callingserver;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;

import java.util.Objects;

import com.azure.communication.callingserver.implementation.CallConnectionsImpl;
import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
import com.azure.communication.callingserver.implementation.converters.AddParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.PlayAudioResultConverter;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
import com.azure.communication.callingserver.implementation.models.AddParticipantRequest;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
import com.azure.communication.callingserver.implementation.models.InviteParticipantsRequest;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.callingserver.implementation.models.PlayAudioRequest;
import com.azure.communication.callingserver.models.AddParticipantResult;
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
import com.azure.communication.callingserver.models.PlayAudioOptions;
import com.azure.communication.callingserver.models.PlayAudioResult;
Expand All @@ -27,9 +23,13 @@
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;

import reactor.core.publisher.Mono;

import java.util.Objects;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;

/**
* Async client that supports call connection operations.
*/
Expand Down Expand Up @@ -132,7 +132,7 @@ Mono<PlayAudioResult> playAudioInternal(String audioFileUri, PlayAudioOptions pl
Mono<PlayAudioResult> playAudioInternal(PlayAudioRequest playAudioRequest) {
try {
return callConnectionInternal.playAudioAsync(callConnectionId, playAudioRequest)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(PlayAudioResultConverter.convert(result)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -236,7 +236,7 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.playAudioWithResponseAsync(callConnectionId, playAudioRequest, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response, PlayAudioResultConverter.convert(response.getValue())));
});
Expand All @@ -254,7 +254,8 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
public Mono<Void> hangup() {
try {
return callConnectionInternal.hangupCallAsync(callConnectionId)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.empty());
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -275,7 +276,7 @@ Mono<Response<Void>> hangupWithResponse(Context context) {
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return callConnectionInternal.hangupCallWithResponseAsync(callConnectionId, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -295,7 +296,7 @@ public Mono<CancelAllMediaOperationsResult> cancelAllMediaOperations(String oper
CancelAllMediaOperationsRequest request = new CancelAllMediaOperationsRequest();
request.setOperationContext(operationContext);
return callConnectionInternal.cancelAllMediaOperationsAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(CancelAllMediaOperationsResultConverter.convert(result)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -324,7 +325,7 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.cancelAllMediaOperationsWithResponseAsync(callConnectionId, request, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response, CancelAllMediaOperationsResultConverter.convert(response.getValue())));
});
Expand All @@ -336,25 +337,26 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> addParticipant(
public Mono<AddParticipantResult> addParticipant(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request = InviteParticipantRequestConverter.convert(participant,
AddParticipantRequest request = AddParticipantRequestConverter.convert(participant,
alternateCallerId,
operationContext,
null);
return callConnectionInternal.inviteParticipantsAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
return callConnectionInternal.addParticipantAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(new AddParticipantResult(result.getParticipantId())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -363,35 +365,37 @@ public Mono<Void> addParticipant(
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> addParticipantWithResponse(
public Mono<Response<AddParticipantResult>> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext) {
return addParticipantWithResponse(participant, alternateCallerId, operationContext, null);
}

Mono<Response<Void>> addParticipantWithResponse(
Mono<Response<AddParticipantResult>> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
Context context) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request =
InviteParticipantRequestConverter
AddParticipantRequest request =
AddParticipantRequestConverter
.convert(participant, alternateCallerId, operationContext, null);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.inviteParticipantsWithResponseAsync(callConnectionId, request, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.addParticipantWithResponseAsync(callConnectionId, request, contextValue)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response, new AddParticipantResult(response.getValue().getParticipantId())));
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -408,7 +412,8 @@ Mono<Response<Void>> addParticipantWithResponse(
public Mono<Void> removeParticipant(String participantId) {
try {
return callConnectionInternal.removeParticipantAsync(callConnectionId, participantId)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.empty());
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -431,7 +436,7 @@ Mono<Response<Void>> removeParticipantWithResponse(String participantId, Context
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.removeParticipantWithResponseAsync(callConnectionId, participantId, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Loading

0 comments on commit faf0204

Please sign in to comment.