Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public class CallAutomationClient
internal CallRecordingRestClient CallRecordingRestClient { get; }
internal CallDialogRestClient CallDialogRestClient { get; }
internal CallAutomationEventProcessor EventProcessor { get; }
internal CommunicationUserIdentifier Source { get; }

/// <summary>
/// CommunicationUserIdentifier that makes the outbound call.
/// This can be provided by providing CallAutomationClientOption during construction of CallAutomationClient.
/// If left blank, service will create one each request.
/// </summary>
public CommunicationUserIdentifier Source { get; }

#region public constructors
/// <summary> Initializes a new instance of <see cref="CallAutomationClient"/>.</summary>
Expand Down Expand Up @@ -233,21 +239,11 @@ public virtual Response<AnswerCallResult> AnswerCall(AnswerCallOptions options,

private AnswerCallRequestInternal CreateAnswerCallRequest(AnswerCallOptions options)
{
// validate callbackUri
if (!IsValidHttpsUri(options.CallbackUri))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidHttpsUriMessage);
}

AnswerCallRequestInternal request = new AnswerCallRequestInternal(options.IncomingCallContext, options.CallbackUri.AbsoluteUri);
// Add custom cognitive service domain name
if (options.AzureCognitiveServicesEndpointUrl != null)
if (options.AzureCognitiveServicesEndpointUri != null)
{
if (!IsValidHttpsUri(options.AzureCognitiveServicesEndpointUrl))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidCognitiveServiceHttpsUriMessage);
}
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUrl.AbsoluteUri;
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUri.AbsoluteUri;
}
request.MediaStreamingConfiguration = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
request.AnsweredByIdentifier = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id);
Expand Down Expand Up @@ -622,13 +618,9 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
options.CallInvite.CustomContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomContext.VoipHeaders);

// Add custom cognitive service domain name
if (options.AzureCognitiveServicesEndpointUrl != null)
if (options.AzureCognitiveServicesEndpointUri != null)
{
if (!IsValidHttpsUri(options.AzureCognitiveServicesEndpointUrl))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidCognitiveServiceHttpsUriMessage);
}
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUrl.AbsoluteUri;
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUri.AbsoluteUri;
}
request.OperationContext = options.OperationContext;
request.MediaStreamingConfiguration = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
Expand All @@ -654,13 +646,9 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
options.CustomContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomContext.VoipHeaders);

// Add custom cognitive service domain name
if (options.AzureCognitiveServicesEndpointUrl != null)
if (options.AzureCognitiveServicesEndpointUri != null)
{
if (!IsValidHttpsUri(options.AzureCognitiveServicesEndpointUrl))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidCognitiveServiceHttpsUriMessage);
}
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUrl.AbsoluteUri;
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUri.AbsoluteUri;
}
request.OperationContext = options.OperationContext;
request.MediaStreamingConfiguration = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
Expand Down Expand Up @@ -736,24 +724,5 @@ public virtual CallAutomationEventProcessor GetEventProcessor()
throw;
}
}

/// <summary>
/// Get source identity used by Call Automation client.
/// </summary>
/// <returns></returns>
public virtual CommunicationUserIdentifier GetSourceIdentity()
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallAutomationClient)}.{nameof(GetSourceIdentity)}");
scope.Start();
try
{
return Source;
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}
}
}
Loading