Esempio n. 1
0
        /// <summary>
        /// Retrieves the application configuration and begins running the
        /// sample.
        /// </summary>
        public void Run()
        {
            try
            {
                _helper      = new UCMASampleHelper();
                _appEndpoint = _helper.CreateApplicationEndpoint("TrustedConferenceParticipant");

                if (_appEndpoint.State == LocalEndpointState.Established)
                {
                    Console.WriteLine("The Application Endpoint owned by URI {0}, is now established and "
                                      + "registered.", _appEndpoint.OwnerUri);
                }
                else
                {
                    Console.WriteLine("The Application endpoint is not currently in the Established state, "
                                      + "exiting...");
                    return;
                }

                // Impersonate a user and create an ad-hoc conference.
                ImpersonateAndCreateConference();

                // Have the application endpoint join the ad-hoc conference as a
                // trusted participant.
                JoinConferenceAsTrustedParticipant();

                // Start monitoring the AVMCU session for attendance changes.
                StartAVMCUSessionAttendanceMonitoring();

                int invitationCounter = 1;
                while (true)
                {
                    // Retrieve the uri of the user to be invited from the
                    // config file.
                    string prompt = "Please enter the uri of the user who should be sent an invitation to the"
                                    + "conference (Enter to Skip) => ";

                    string invitationTargetUri = UCMASampleHelper.PromptUser(prompt, "InvitationTargetURI"
                                                                             + invitationCounter);
                    if (!string.IsNullOrEmpty(invitationTargetUri))
                    {
                        InviteUserToConference(invitationTargetUri);
                        invitationCounter++;

                        if (_invitedParticipantAccepted)
                        {
                            // Wait for the invited participant to have the
                            // Trusted User establish an Av call and update the
                            // audio routes to communicate with them. This is
                            // purely so the logging for each invited user
                            // occurs in sequence for this sample.
                            Console.WriteLine("Waiting for the AudioRoute update on the Av Call for the new "
                                              + "participant to complete.");
                            _audioRouteUpdateForNewParticipantCallCompleted.WaitOne();
                        }
                    }
                    else
                    {
                        Console.WriteLine("No invitation uri provided, skipping conference invitation.");
                        break;
                    }
                }

                Console.WriteLine(RetrieveConversationParticipantsProperties(
                                      _impersonatingAvCall.Conversation));

                Console.Write("\n\n********************\n");
                Console.WriteLine("Press enter to exit.");
                Console.WriteLine("********************\n\n");
                Console.ReadLine();
            }
            finally
            {
                //Terminate the platform which would in turn terminate any
                // endpoints.
                Console.WriteLine("Shutting down the platform.");
                _helper.ShutdownPlatform();
            }
        }