private async Task <Response <CreateCallResponse> > CreateCallOperation(CallClient client) { CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient(); var source = await CreateUserAsync(communicationIdentityClient).ConfigureAwait(false); var targets = new List <CommunicationIdentifier>() { new PhoneNumberIdentifier(TestEnvironment.TargetPhoneNumber) }; var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), new List <CallModality> { CallModality.Audio }, new List <EventSubscriptionType> { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); createCallOption.AlternateCallerId = new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber); Console.WriteLine("Performing CreateCall operation"); var createCallResponse = await client.CreateCallAsync(source : source, targets : targets, options : createCallOption).ConfigureAwait(false); Console.WriteLine("Call initiated with Call Leg id: {0}", createCallResponse.Value.CallLegId); Assert.IsFalse(string.IsNullOrWhiteSpace(createCallResponse.Value.CallLegId)); return(createCallResponse); }
public async Task PlayAudioTest() { CallClient client = CreateInstrumentedCallingServerClient(); try { var createCallResponse = await CreateCallOperation(client).ConfigureAwait(false); var callLegId = createCallResponse.Value.CallLegId; await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); await PlayAudioOperation(client, callLegId).ConfigureAwait(false); await DeteleCallOperation(client, callLegId).ConfigureAwait(false); } catch (RequestFailedException ex) { Console.WriteLine(ex.Message); Assert.Fail($"Unexpected error: {ex}"); } catch (Exception ex) { Assert.Fail($"Unexpected error: {ex}"); } }
public void CreateCall() { CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClient(TestEnvironment.LiveTestDynamicConnectionString); var source = communicationIdentityClient.CreateUser(); var targets = new List <CommunicationIdentifier>() { new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber) }; var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), new List <CallModality> { CallModality.Audio }, new List <EventSubscriptionType> { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); CallClient callClient = CreateInstrumentedCallingServerClient(); Console.WriteLine("Performing CreateCall operation"); #region Snippet:Azure_Communication_Call_Tests_CreateCall CreateCallResponse createCallResponse = callClient.CreateCall( //@@ source: new CommunicationUserIdentifier("<source-identifier>"), // Your Azure Communication Resource Guid Id used to make a Call //@@ targets: new List<CommunicationIdentifier>() { new PhoneNumberIdentifier("<targets-phone-number>") }, // E.164 formatted recipient phone number //@@ options: createCallOption // The options for creating a call. /*@@*/ source: source, /*@@*/ targets: targets, /*@@*/ options: createCallOption ); Console.WriteLine($"Call Leg id: {createCallResponse.CallLegId}"); #endregion Snippet:Azure_Communication_Call_Tests_CreateCall }
private async Task CancelAllMediaOperationsOperation(CallClient client, string callLegId) { Console.WriteLine("Performing cancel media processing operation to stop playing audio"); var response = await client.CancelAllMediaOperationsAsync(callLegId).ConfigureAwait(false); Assert.AreEqual(OperationStatus.Completed, response.Value.Status); }
private async Task HangupOperation(CallClient client, string callLegId) { Console.WriteLine("Performing Hangup operation"); var response = await client.HangupCallAsync(callLegId).ConfigureAwait(false); Assert.AreEqual(202, response.Status); }
private async Task DeteleCallOperation(CallClient client, string callLegId) { var response = await client.DeleteCallAsync(callLegId : callLegId).ConfigureAwait(false); Console.WriteLine("Delete Call with Call Leg id: {0}", callLegId); Assert.AreEqual(202, response.Status); Assert.IsFalse(string.IsNullOrWhiteSpace(response.ClientRequestId)); }
public async Task <bool> Init(string token) { var credentials = new CommunicationTokenCredential(token); _callClient = new CallClient(); var callOptions = new CallAgentOptions(); _callAgent = Com.Laerdal.Azurecommunicationhelper.CallClientHelper.GetCallAgent(_callClient, Application.Context, credentials); _deviceManager = Com.Laerdal.Azurecommunicationhelper.CallClientHelper.GetDeviceManager(_callClient, Application.Context); return(true); }
public async Task <bool> Init(string token) { var credentials = new CommunicationTokenCredential(token); _callClient = new CallClient(); _callAgent = (CallAgent)await _callClient.CreateCallAgent(Application.Context, credentials).GetAsync(); _deviceManager = (DeviceManager)await _callClient.DeviceManager.GetAsync(); return(true); }
/// <summary> /// Creates a <see cref="CallClient" /> /// </summary> /// <returns>The instrumented <see cref="CallClient" />.</returns> protected CallClient CreateInstrumentedCallingServerClient() { var connectionString = TestEnvironment.LiveTestStaticConnectionString; CallClient client = new CallClient(connectionString, CreateServerCallingClientOptionsWithCorrelationVectorLogs()); #region Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient //@@var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal //@@CallClient client = new CallClient(connectionString); #endregion Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient return(InstrumentClient(client)); }
private async Task PlayAudioOperation(CallClient client, string callLegId) { var playAudioOptions = new PlayAudioOptions() { AudioFileUri = new Uri(TestEnvironment.AudioFileUrl), OperationContext = "de346f03-7f8d-41ab-a232-cc5e14990769", Loop = true, AudioFileId = "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" }; Console.WriteLine("Performing PlayAudio operation"); var response = await client.PlayAudioAsync(callLegId, playAudioOptions).ConfigureAwait(false); Assert.AreEqual(response.Value.Status, OperationStatus.Running); }
public async Task CreateCallTest() { CallClient client = CreateInstrumentedCallingServerClient(); try { await CreateCallOperation(client).ConfigureAwait(false); } catch (RequestFailedException ex) { Console.WriteLine(ex.Message); Assert.Fail($"Unexpected error: {ex}"); } catch (Exception ex) { Assert.Fail($"Unexpected error: {ex}"); } }
private async void CallButton_ClickAsync(object sender, RoutedEventArgs e) { CommunicationTokenCredential token_credential = new CommunicationTokenCredential("<USER_ACCESS_TOKEN>"); call_client_ = new CallClient(); CallAgentOptions callAgentOptions = new CallAgentOptions() { DisplayName = "<YOUR_DISPLAY_NAME>" }; call_agent_ = await call_client_.CreateCallAgent(token_credential, callAgentOptions); StartCallOptions startCallOptions = new StartCallOptions(); ICommunicationIdentifier[] callees = new ICommunicationIdentifier[1] { new CommunicationUserIdentifier(CalleeTextBox.Text) }; call_ = await call_agent_.StartCallAsync(callees, startCallOptions); }
public async Task HangupCallTest() { CallClient client = CreateInstrumentedCallingServerClient(); try { var createCallResponse = await CreateCallOperation(client).ConfigureAwait(false); var callLegId = createCallResponse.Value.CallLegId; // There is one call leg in this test case, hangup the call will also delete the call as the result. await HangupOperation(client, callLegId).ConfigureAwait(false); } catch (RequestFailedException ex) { Console.WriteLine(ex.Message); Assert.Fail($"Unexpected error: {ex}"); } catch (Exception ex) { Assert.Fail($"Unexpected error: {ex}"); } }
public MainPage() { InitializeComponent(); call_client = new(); }