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);
        }
Exemplo n.º 2
0
        public async Task CreateCallAsync()
        {
            CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClient(TestEnvironment.LiveTestDynamicConnectionString);
            var source = await communicationIdentityClient.CreateUserAsync();

            var targets = new List <CommunicationIdentifier>()
            {
                new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber)
            };

            #region Snippet:Azure_Communication_Call_Tests_CreateCallOptions
            var createCallOption = new CreateCallOptions(
                new Uri(TestEnvironment.AppCallbackUrl),
                new List <CallModality> {
                CallModality.Audio
            },
                new List <EventSubscriptionType>
            {
                EventSubscriptionType.ParticipantsUpdated,
                EventSubscriptionType.DtmfReceived
            });
            #endregion Snippet:Azure_Communication_Call_Tests_CreateCallOptions
            CallClient callClient = CreateInstrumentedCallingServerClient();
            Console.WriteLine("Performing CreateCall operation");
            #region Snippet:Azure_Communication_Call_Tests_CreateCallAsync
            CreateCallResponse createCallResponse = await callClient.CreateCallAsync(
                //@@ 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_CreateCallAsync
        }