diff --git a/sdk/communication/azure-communication-callingserver/CHANGELOG.md b/sdk/communication/azure-communication-callingserver/CHANGELOG.md index 542b71925cf75..4c3dbd241a616 100644 --- a/sdk/communication/azure-communication-callingserver/CHANGELOG.md +++ b/sdk/communication/azure-communication-callingserver/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## 1.0.0-beta.1 (Unreleased) -This is the first release of Azure Communication CallingServer Service. For more information, please see the [README][read_me]. +This is the first release of Azure Communication Calling Server Service. For more information, please see the [README][read_me]. This is a Public Preview version, so breaking changes are possible in subsequent releases as we improve the product. To provide feedback, please submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues). diff --git a/sdk/communication/azure-communication-callingserver/README.md b/sdk/communication/azure-communication-callingserver/README.md index bcbaf85377101..f034ef5728279 100644 --- a/sdk/communication/azure-communication-callingserver/README.md +++ b/sdk/communication/azure-communication-callingserver/README.md @@ -21,7 +21,7 @@ This package contains a Java SDK for Azure Communication CallingServer Service. com.azure azure-communication-callingserver - 1.0.0-preview.1 + 1.0.0-beta.1 ``` [//]: # ({x-version-update-end}) @@ -91,8 +91,6 @@ CreateCallOptions createCallOptions = new CreateCallOptions( requestedCallEvents); CreateCallResponse createCallResult = callClient.createCall(source, targets, createCallOptions); - -String callId = createCallResult.getCallLegId(); ``` Add a participant to a Call: @@ -137,7 +135,6 @@ Start a Recording: String conversationId = ""; String recordingStateCallbackUri = ""; StartCallRecordingResponse response = conversationClient.startRecording(conversationId, recordingStateCallbackUri); -String recordingId = response.getRecordingId(); ``` Pause a Recording: @@ -180,8 +177,8 @@ Play Audio: String audioFileUri = ""; String audioFileId = ""; String callbackUri = ""; -String context = ""; -PlayAudioResponse playAudioResponse = conversationClient.playAudio(conversationId, audioFileUri, audioFileId, callbackUri, context); +String context = ""; +PlayAudioResponse playAudioResponse = conversationClient.playAudio(conversationId, audioFileUri, audioFileId, callbackUri, context); ``` ## Troubleshooting diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallAsyncClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallAsyncClient.java index e9b6e5529fdac..508aac3f2c17d 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallAsyncClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallAsyncClient.java @@ -34,7 +34,6 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; @@ -67,11 +66,9 @@ public Mono createCall(CommunicationIdentifier source, try { Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(targets, "'targets' cannot be null."); - Objects.requireNonNull(createCallOptions, "'CreateCallOptions' cannot be null."); + Objects.requireNonNull(createCallOptions, "'createCallOptions' cannot be null."); CreateCallRequestInternal request = createCreateCallRequest(source, targets, createCallOptions); - return this.callClient - .createCallAsync(request) - .flatMap(response -> Mono.just(response)); + return this.callClient.createCallAsync(request); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -103,9 +100,7 @@ Mono> createCallWithResponse(CommunicationIdentifie CreateCallRequestInternal request = createCreateCallRequest(source, targets, createCallOptions); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.callClient - .createCallWithResponseAsync(request, contextValue) - .flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue()))); + return this.callClient.createCallWithResponseAsync(request, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -132,15 +127,9 @@ public Mono playAudio(String callId, String audioFileId, String callbackUri, String operationContext) { - try { - Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null."); - PlayAudioRequest playAudioRequest = - PlayAudioConverter.convert(audioFileUri, loop, audioFileId, callbackUri, operationContext); - return playAudio(callId, playAudioRequest); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + PlayAudioRequest playAudioRequest = + PlayAudioConverter.convert(audioFileUri, loop, audioFileId, callbackUri, operationContext); + return playAudio(callId, playAudioRequest); } /** @@ -157,24 +146,16 @@ public Mono playAudio(String callId, public Mono playAudio(String callId, String audioFileUri, PlayAudioOptions playAudioOptions) { - try { - Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null."); - PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions); - return playAudio(callId, playAudioRequest); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions); + return playAudio(callId, playAudioRequest); + } Mono playAudio(String callId, PlayAudioRequest playAudioRequest) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null."); - - return this.callClient - .playAudioAsync(callId, playAudioRequest) - .flatMap(response -> Mono.just(response)); + Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null."); + return this.callClient.playAudioAsync(callId, playAudioRequest); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -223,15 +204,15 @@ public Mono> playAudioWithResponse(String callId, return playAudioWithResponse(callId, playAudioRequest, Context.NONE); } - Mono> playAudioWithResponse(String callId, PlayAudioRequest playAudioRequest, Context context) { + Mono> playAudioWithResponse(String callId, + PlayAudioRequest playAudioRequest, + Context context) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null."); + Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.callClient - .playAudioWithResponseAsync(callId, playAudioRequest, contextValue) - .flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue()))); + return this.callClient.playAudioWithResponseAsync(callId, playAudioRequest, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -287,7 +268,6 @@ Mono> hangupCallWithResponse(String callId, Context context) { public Mono deleteCall(String callId) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - return this.callClient.deleteCallAsync(callId); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -328,12 +308,9 @@ Mono> deleteCallWithResponse(String callId, Context context) { public Mono cancelAllMediaOperations(String callId, String operationContext) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - CancelAllMediaOperationsRequest request = new CancelAllMediaOperationsRequest(); request.setOperationContext(operationContext); - return this.callClient - .cancelAllMediaOperationsAsync(callId, request) - .flatMap(response -> Mono.just(response)); + return this.callClient.cancelAllMediaOperationsAsync(callId, request); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -361,9 +338,7 @@ Mono> cancelAllMediaOperationsWithRes request.setOperationContext(operationContext); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.callClient - .cancelAllMediaOperationsWithResponseAsync(callId, request, contextValue) - .flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue()))); + return this.callClient.cancelAllMediaOperationsWithResponseAsync(callId, request, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -386,7 +361,7 @@ public Mono addParticipant(String callId, String operationContext) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(participant, "'request' cannot be null."); + Objects.requireNonNull(participant, "'participant' cannot be null."); InviteParticipantsRequest request = AddParticipantConverter.convert(participant, alternateCallerId, operationContext, @@ -447,7 +422,7 @@ Mono> addParticipantWithResponse(String callId, public Mono removeParticipant(String callId, String participantId) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(participantId, "'request' cannot be null."); + Objects.requireNonNull(participantId, "'participantId' cannot be null."); return this.callClient.removeParticipantAsync(callId, participantId); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -472,7 +447,7 @@ public Mono> removeParticipantWithResponse(String callId, String Mono> removeParticipantWithResponse(String callId, String participantId, Context context) { try { Objects.requireNonNull(callId, "'callId' cannot be null."); - Objects.requireNonNull(participantId, "'request' cannot be null."); + Objects.requireNonNull(participantId, "'participantId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return this.callClient.removeParticipantWithResponseAsync(callId, participantId, contextValue); diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallClient.java index abe51e97c8a31..f0c27d701885f 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallClient.java @@ -218,9 +218,7 @@ public CancelAllMediaOperationsResponse cancelAllMediaOperations(String callId, public Response cancelAllMediaOperationsWithResponse(String callId, String operationContext, Context context) { - return callAsyncClient.cancelAllMediaOperationsWithResponse(callId, - operationContext, - context).block(); + return callAsyncClient.cancelAllMediaOperationsWithResponse(callId, operationContext, context).block(); } /** diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ConversationAsyncClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ConversationAsyncClient.java index 4fdb3553ea3b8..3085793ee63c3 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ConversationAsyncClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ConversationAsyncClient.java @@ -22,7 +22,6 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.http.rest.Response; -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; @@ -63,8 +62,8 @@ public Mono joinCall(String conversationId, Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null."); - return this.conversationsClient.joinCallAsync(conversationId, - JoinCallConverter.convert(source, joinCallOptions)); + return this.conversationsClient + .joinCallAsync(conversationId, JoinCallConverter.convert(source, joinCallOptions)); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -91,11 +90,12 @@ Mono> joinCallWithResponse(String conversationId, Context context) { try { Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); - Objects.requireNonNull(source, "'request' cannot be null."); + Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.conversationsClient.joinCallWithResponseAsync(conversationId, + return this.conversationsClient. + joinCallWithResponseAsync(conversationId, JoinCallConverter.convert(source, joinCallOptions), contextValue); }); @@ -123,10 +123,11 @@ public Mono addParticipant(String conversationId, try { Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); Objects.requireNonNull(participant, "'participant' cannot be null."); - InviteParticipantsRequest request = AddParticipantConverter.convert(participant, - alternateCallerId, - operationContext, - callBackUri); + InviteParticipantsRequest request = + AddParticipantConverter.convert(participant, + alternateCallerId, + operationContext, + callBackUri); return this.conversationsClient.inviteParticipantsAsync(conversationId, request); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -166,14 +167,14 @@ Mono> addParticipantWithResponse(String conversationId, try { Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); Objects.requireNonNull(participant, "'participant' cannot be null."); - InviteParticipantsRequest request = AddParticipantConverter.convert(participant, - alternateCallerId, - operationContext, - callBackUri); + InviteParticipantsRequest request = + AddParticipantConverter.convert(participant, + alternateCallerId, + operationContext, + callBackUri); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.conversationsClient - .inviteParticipantsWithResponseAsync(conversationId, request, contextValue); + return this.conversationsClient.inviteParticipantsWithResponseAsync(conversationId, request, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -219,8 +220,7 @@ Mono> removeParticipantWithResponse(String conversationId, String Objects.requireNonNull(participantId, "'participantId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.conversationsClient - .removeParticipantWithResponseAsync(conversationId, participantId, contextValue); + return this.conversationsClient.removeParticipantWithResponseAsync(conversationId, participantId, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -245,8 +245,7 @@ public Mono startRecording(String conversationId, St } StartCallRecordingRequest request = new StartCallRecordingRequest(); request.setRecordingStateCallbackUri(recordingStateCallbackUri); - return this.conversationsClient.startRecordingAsync(conversationId, request) - .flatMap((StartCallRecordingResponse response) -> Mono.just(response)); + return this.conversationsClient.startRecordingAsync(conversationId, request); } catch (RuntimeException ex) { return monoError(logger, ex); } catch (URISyntaxException ex) { @@ -265,9 +264,7 @@ public Mono startRecording(String conversationId, St @ServiceMethod(returns = ReturnType.SINGLE) public Mono> startRecordingWithResponse(String conversationId, String recordingStateCallbackUri) { - return startRecordingWithResponse(conversationId, - recordingStateCallbackUri, - Context.NONE); + return startRecordingWithResponse(conversationId, recordingStateCallbackUri, Context.NONE); } Mono> startRecordingWithResponse(String conversationId, @@ -283,10 +280,7 @@ Mono> startRecordingWithResponse(String con request.setRecordingStateCallbackUri(recordingStateCallbackUri); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; - return this.conversationsClient - .startRecordingWithResponseAsync(conversationId, request, contextValue) - .flatMap((Response response) - -> Mono.just(new SimpleResponse<>(response, response.getValue()))); + return this.conversationsClient.startRecordingWithResponseAsync(conversationId, request, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -439,8 +433,7 @@ public Mono getRecordingState(String conversationId, try { Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); - return this.conversationsClient.recordingStateAsync(conversationId, recordingId) - .flatMap((CallRecordingStateResponse response) -> Mono.just(response)); + return this.conversationsClient.recordingStateAsync(conversationId, recordingId); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -468,8 +461,7 @@ Mono> getRecordingStateWithResponse(String return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return this.conversationsClient - .recordingStateWithResponseAsync(conversationId, recordingId, contextValue) - .flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue()))); + .recordingStateWithResponseAsync(conversationId, recordingId, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -521,24 +513,15 @@ public Mono playAudio(String conversationId, public Mono playAudio(String conversationId, String audioFileUri, PlayAudioOptions playAudioOptions) { - try { - Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); - Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null."); - - //Currently we do not support loop on the audio media for out-call, thus setting the loop to false - PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions); - return playAudio(conversationId, playAudioRequest); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions); + return playAudio(conversationId, playAudioRequest); } Mono playAudio(String conversationId, PlayAudioRequest playAudioRequest) { try { Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); - Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null."); - return this.conversationsClient.playAudioAsync(conversationId, playAudioRequest) - .flatMap(response -> Mono.just(response)); + Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null."); + return this.conversationsClient.playAudioAsync(conversationId, playAudioRequest); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -557,7 +540,11 @@ Mono playAudio(String conversationId, PlayAudioRequest playAu * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> playAudioWithResponse(String conversationId, String audioFileUri, String audioFileId, String callbackUri, String operationContext) { + public Mono> playAudioWithResponse(String conversationId, + String audioFileUri, + String audioFileId, + String callbackUri, + String operationContext) { //Currently we do not support loop on the audio media for out-call, thus setting the loop to false PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, false, audioFileId, callbackUri, operationContext); @@ -578,7 +565,6 @@ public Mono> playAudioWithResponse(String conversati public Mono> playAudioWithResponse(String conversationId, String audioFileUri, PlayAudioOptions playAudioOptions) { - //Currently we do not support loop on the audio media for out-call, thus setting the loop to false PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions); return playAudioWithResponse(conversationId, playAudioRequest, Context.NONE); } @@ -588,12 +574,11 @@ Mono> playAudioWithResponse(String conversationId, Context context) { try { Objects.requireNonNull(conversationId, "'conversationId' cannot be null."); - Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null."); + Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return this.conversationsClient - .playAudioWithResponseAsync(conversationId, playAudioRequest, contextValue) - .flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue()))); + .playAudioWithResponseAsync(conversationId, playAudioRequest, contextValue); }); } catch (RuntimeException ex) { return monoError(logger, ex); diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java index 145f845b67a21..c4d99ead34b1a 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java @@ -85,9 +85,7 @@ public String getCallbackUri() { * @return the requested modalities object itself. */ public CallModality[] getRequestedModalities() { - CallModality[] requestedModalities = new CallModality[this.requestedModalities.length]; - System.arraycopy(this.requestedModalities, 0, requestedModalities, 0, this.requestedModalities.length); - return requestedModalities; + return this.requestedModalities == null ? new CallModality[0] : this.requestedModalities.clone(); } /** @@ -101,9 +99,7 @@ public CallModality[] getRequestedModalities() { * @return the requested call events to subscribe to object itself. */ public EventSubscriptionType[] getRequestedCallEvents() { - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[this.requestedCallEvents.length]; - System.arraycopy(this.requestedCallEvents, 0, requestedCallEvents, 0, this.requestedCallEvents.length); - return requestedCallEvents; + return this.requestedCallEvents.clone(); } /** @@ -130,10 +126,7 @@ public CreateCallOptions(String callbackUri, this.callbackUri = callbackUri; - this.requestedModalities = new CallModality[requestedModalities.length]; - System.arraycopy(requestedModalities, 0, this.requestedModalities, 0, requestedModalities.length); - - this.requestedCallEvents = new EventSubscriptionType[requestedCallEvents.length]; - System.arraycopy(requestedCallEvents, 0, this.requestedCallEvents, 0, requestedCallEvents.length); + this.requestedModalities = requestedModalities.clone(); + this.requestedCallEvents = requestedCallEvents.clone(); } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java index b1cf6f8a4ed77..d12306f80ca14 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java @@ -79,12 +79,7 @@ public JoinCallOptions setCallbackUri(String callbackUri) { * @return the requestedModalities value. */ public CallModality[] getRequestedModalities() { - if (this.requestedModalities == null) { - return new CallModality[0]; - } - CallModality[] requestedModalities = new CallModality[this.requestedModalities.length]; - System.arraycopy(this.requestedModalities, 0, requestedModalities, 0, this.requestedModalities.length); - return requestedModalities; + return this.requestedModalities == null ? new CallModality[0] : this.requestedModalities.clone(); } /** @@ -94,8 +89,7 @@ public CallModality[] getRequestedModalities() { * @return the JoinCallOptions object itself. */ public JoinCallOptions setRequestedModalities(CallModality[] requestedModalities) { - this.requestedModalities = new CallModality[requestedModalities.length]; - System.arraycopy(requestedModalities, 0, this.requestedModalities, 0, requestedModalities.length); + this.requestedModalities = requestedModalities == null ? new CallModality[0] : requestedModalities.clone(); return this; } @@ -106,12 +100,7 @@ public JoinCallOptions setRequestedModalities(CallModality[] requestedModalities * @return the requestedCallEvents value. */ public EventSubscriptionType[] getRequestedCallEvents() { - if (this.requestedCallEvents == null) { - return new EventSubscriptionType[0]; - } - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[this.requestedCallEvents.length]; - System.arraycopy(this.requestedCallEvents, 0, requestedCallEvents, 0, this.requestedCallEvents.length); - return requestedCallEvents; + return this.requestedCallEvents == null ? new EventSubscriptionType[0] : this.requestedCallEvents.clone(); } /** @@ -122,8 +111,7 @@ public EventSubscriptionType[] getRequestedCallEvents() { * @return the JoinCallOptions object itself. */ public JoinCallOptions setRequestedCallEvents(EventSubscriptionType[] requestedCallEvents) { - this.requestedCallEvents = new EventSubscriptionType[requestedCallEvents.length]; - System.arraycopy(requestedCallEvents, 0, this.requestedCallEvents, 0, requestedCallEvents.length); + this.requestedCallEvents = requestedCallEvents == null ? new EventSubscriptionType[0] : requestedCallEvents.clone(); return this; } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java index 7828215075e52..386c178e5c50a 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java @@ -52,9 +52,7 @@ public ParticipantsUpdatedEvent setCallLegId(String callLegId) { * @return the result info value. */ public CommunicationParticipant[] getParticipants() { - CommunicationParticipant[] participants = new CommunicationParticipant[this.participants.length]; - System.arraycopy(this.participants, 0, participants, 0, this.participants.length); - return participants; + return this.participants == null ? new CommunicationParticipant[0] : this.participants.clone(); } /** @@ -64,8 +62,7 @@ public CommunicationParticipant[] getParticipants() { * @return the ParticipantsUpdatedEvent object itself. */ public ParticipantsUpdatedEvent setParticipants(CommunicationParticipant[] participants) { - this.participants = new CommunicationParticipant[participants.length]; - System.arraycopy(participants, 0, this.participants, 0, participants.length); + this.participants = participants == null ? new CommunicationParticipant[0] : participants.clone(); return this; } @@ -90,11 +87,8 @@ public ParticipantsUpdatedEvent(String callLegId, CommunicationParticipant[] par if (participants == null) { throw new IllegalArgumentException("object participants cannot be null"); } - this.callLegId = callLegId; - - this.participants = new CommunicationParticipant[participants.length]; - System.arraycopy(participants, 0, this.participants, 0, participants.length); + this.participants = participants.clone(); } /** diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java index e45edc286c632..62b5cc7e50cf4 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java @@ -71,8 +71,6 @@ public void createCall() { requestedCallEvents); CreateCallResponse createCallResult = callClient.createCall(source, targets, createCallOptions); - - String callId = createCallResult.getCallLegId(); } /** diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAsyncClientTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAsyncClientTests.java index fdbdddafbadc3..735fbb236be00 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAsyncClientTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAsyncClientTests.java @@ -16,7 +16,6 @@ import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -98,8 +97,7 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl Response createCallResponse = callAsyncClient.createCallWithResponse( new CommunicationUserIdentifier(from), new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, - options, - Context.NONE).block(); + options).block(); CallingServerTestUtils.validateCreateCallResponse(createCallResponse); String callId = createCallResponse.getValue().getCallLegId(); @@ -117,11 +115,11 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl // Cancel All Media Operations String cancelMediaOperationContext = "ac794123-3820-4979-8e2d-50c7d3e07b13"; - Response cancelAllMediaOperationsResponse = callAsyncClient.cancelAllMediaOperationsWithResponse(callId, cancelMediaOperationContext, Context.NONE).block(); + Response cancelAllMediaOperationsResponse = callAsyncClient.cancelAllMediaOperationsWithResponse(callId, cancelMediaOperationContext).block(); CallingServerTestUtils.validateCancelAllMediaOperationsResponse(cancelAllMediaOperationsResponse, cancelMediaOperationContext); // Hang up - Response hangupResponse = callAsyncClient.hangupCallWithResponse(callId, Context.NONE).block(); + Response hangupResponse = callAsyncClient.hangupCallWithResponse(callId).block(); CallingServerTestUtils.validateResponse(hangupResponse); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -186,24 +184,23 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli Response createCallResponse = callAsyncClient.createCallWithResponse( new CommunicationUserIdentifier(from), new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, - options, - Context.NONE).block(); + options).block(); CallingServerTestUtils.validateCreateCallResponse(createCallResponse); String callId = createCallResponse.getValue().getCallLegId(); // Invite User String operationContext = "ac794123-3820-4979-8e2d-50c7d3e07b12"; - Response inviteParticipantResponse = callAsyncClient.addParticipantWithResponse(callId, new CommunicationUserIdentifier(invitedUser), null, operationContext, Context.NONE).block(); + Response inviteParticipantResponse = callAsyncClient.addParticipantWithResponse(callId, new CommunicationUserIdentifier(invitedUser), null, operationContext).block(); CallingServerTestUtils.validateResponse(inviteParticipantResponse); // Remove Participant String participantId = "4c100bf4-304c-48e0-87a8-03597ec75464"; - Response removeParticipantResponse = callAsyncClient.removeParticipantWithResponse(callId, participantId, Context.NONE).block(); + Response removeParticipantResponse = callAsyncClient.removeParticipantWithResponse(callId, participantId).block(); CallingServerTestUtils.validateResponse(removeParticipantResponse); // Hang up - Response hangupResponse = callAsyncClient.hangupCallWithResponse(callId, Context.NONE).block(); + Response hangupResponse = callAsyncClient.hangupCallWithResponse(callId).block(); CallingServerTestUtils.validateResponse(hangupResponse); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -260,14 +257,13 @@ public void runCreateDeleteScenarioWithResponseAsync(HttpClient httpClient) thro Response createCallResponse = callAsyncClient.createCallWithResponse( new CommunicationUserIdentifier(from), new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, - options, - Context.NONE).block(); + options).block(); CallingServerTestUtils.validateCreateCallResponse(createCallResponse); String callId = createCallResponse.getValue().getCallLegId(); // Delete Call - Response hangupResponse = callAsyncClient.deleteCallWithResponse(callId, Context.NONE).block(); + Response hangupResponse = callAsyncClient.deleteCallWithResponse(callId).block(); CallingServerTestUtils.validateResponse(hangupResponse); } catch (Exception e) { System.out.println("Error: " + e.getMessage());