Exemple #1
0
        // Returns the remote user URI.
        public String GetRemoteUserURI()
        {
            String str = "";

            try
            {
                if (ConfigurationManager.AppSettings[_remoteUserURIPrompt + _userCount] != null)
                {
                    _remoteUserURI = ConfigurationManager.AppSettings[_remoteUserURIPrompt + _userCount];
                    Console.WriteLine("\nUsing {0} as remote user", _remoteUserURI);
                    return(_remoteUserURI);
                }
                else
                {
                    // Prompt user for remote user URI
                    _remoteUserURI = UCMASampleHelper.PromptUser("Enter the URI for the remote user logged onto Communicator, in the sip:User@Host format or tel:+1XXXYYYZZZZ format => ", "RemoteUserURI");
                    return(str);
                }
            }
            catch (InvalidOperationException iOpEx)
            {
                // Invalid Operation Exception should only be thrown on poorly-entered input.
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
                return(str);
            }
        }
Exemple #2
0
        public AudioVideoFlow CreateAudioVideoFlow(EventHandler <AudioVideoFlowConfigurationRequestedEventArgs> audioVideoFlowConfigurationRequestedEventHandler, EventHandler <MediaFlowStateChangedEventArgs> audioVideoFlowStateChangedEventHandler)
        {
            _audioVideoFlowConfigurationRequestedEventHandler = audioVideoFlowConfigurationRequestedEventHandler;
            _audioVideoFlowStateChangedEventHandler           = audioVideoFlowStateChangedEventHandler;

            UCMASampleHelper UCMASampleHelper = new UCMASampleHelper();
            UserEndpoint     userEndpoint     = UCMASampleHelper.CreateEstablishedUserEndpoint("AudioVideoFlowHelper");

            // If application settings are provided via the app.config file, then use them
            if (ConfigurationManager.AppSettings.HasKeys() == true)
            {
                _calledParty = "sip:" + ConfigurationManager.AppSettings["CalledParty"];
            }
            else
            {
                // Prompt user for user URI
                string prompt = "Please enter the Called Party URI in the User@Host format => ";
                _calledParty = UCMASampleHelper.PromptUser(prompt, "Remote User URI");
                _calledParty = "sip:" + _calledParty;
            }

            // Setup the conversation and place the call.
            ConversationSettings convSettings = new ConversationSettings();

            convSettings.Priority = _conversationPriority;
            convSettings.Subject  = _conversationSubject;

            // Conversation represents a collection of modes of communication (media types)in the context of a dialog with one or multiple callees.
            Conversation   conversation   = new Conversation(userEndpoint, convSettings);
            AudioVideoCall audioVideoCall = new AudioVideoCall(conversation);

            //Call: StateChanged: Only hooked up for logging.
            audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged);

            //Subscribe for the flow configuration requested event; the flow will be used to send the media.
            //Ultimately, as a part of the callback, the media will be sent/recieved.
            audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(audioVideoCall_FlowConfigurationRequested);

            //Place the call to the remote party, with the default call options.
            audioVideoCall.BeginEstablish(_calledParty, null, EndCallEstablish, audioVideoCall);

            //Sync; wait for the call to complete.
            _waitForAudioVideoCallEstablishCompleted.WaitOne();

            //Sync; wait for the AudioVideoFlow goes Active
            _waitForAudioVideoFlowStateChangedToActiveCompleted.WaitOne();

            return(_audioVideoFlow);
        }
Exemple #3
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered
        // event on the
        // CollaborationPlatform for the provisioned application.
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                                 ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            UCMASampleHelper.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of"
                                       + " the CollaborationPlatform.");
            UCMASampleHelper.WriteLine("The ApplicationEndpointOwnerConfiguration that corresponds to the"
                                       + "  provisioned application with ID " + _applicationId + " are: ");
            UCMASampleHelper.WriteLine("Owner display name is: "
                                       + e.ApplicationEndpointSettings.OwnerDisplayName);
            UCMASampleHelper.WriteLine("Owner URI is: " + e.ApplicationEndpointSettings.OwnerUri);
            UCMASampleHelper.WriteLine("Now retrieving the ApplicationEndpointSettings from the "
                                       + "ApplicationEndpointSettingsDiscoveredEventArgs.");
            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.SupportedMimePartContentTypes = new System.Net.Mime.ContentType[] {
                new System.Net.Mime.ContentType("text/plain")
            };

            UCMASampleHelper.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned "
                                       + "application with ID " + _applicationId);

            // Initalize the endpoint using the settings retrieved above.
            _applicationEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event if necessary
            // Wire up the ApplicationEndpointOwnerPropertiesChanged event if necessary
            try
            {
                // Establish the endpoint.
                _applicationEndpoint.BeginEstablish(EndEndpointEstablish, _applicationEndpoint);
            }
            catch (InvalidOperationException iOpEx)
            {
                // Invalid Operation Exception may be thrown if the data provided
                // to the BeginXXX methods was invalid/malformed.
                // TODO (Left to the reader): Error handling code.
                UCMASampleHelper.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Exemple #4
0
        /// <summary>
        /// Returns an application endpoint that is provisioned on a platform
        /// as specified by the ApplicationID which could be provided by config
        /// file or be prompted to the user; if the platform discovers multiple
        /// application endpoints the first one discovered and established will be
        /// returned. If no application endpoints are discovered this method
        /// returns null.
        /// </summary>
        /// <returns></returns>
        public ApplicationEndpoint CreateAutoProvisionedApplicationEndpoint()
        {
            _applicationId = null;
            try
            {
                // Attempt to retrieve the application ID of the provisioned
                // application from the config file.
                _applicationId = System.Configuration.ConfigurationManager.AppSettings["ApplicationID"];
                if (string.IsNullOrEmpty(_applicationId))
                {
                    // The application ID wasn't retrieved from the config file
                    // so prompt for the application ID for the application that
                    // has been provisioned.
                    string prompt = "Please enter the unique ID of the application that is provisioned in "
                                    + "the topology => ";
                    _applicationId = UCMASampleHelper.PromptUser(prompt, null);
                }
                if (!string.IsNullOrEmpty(_applicationId))
                {
                    UCMASampleHelper.WriteLine("Creating CollaborationPlatform for the provisioned application"
                                               + " with ID \'" + _applicationId + "\' using ProvisionedApplicationPlatformSettings.");
                    ProvisionedApplicationPlatformSettings settings
                        = new ProvisionedApplicationPlatformSettings("UCMASampleApp", _applicationId);
                    // Reuse platform instance so that all endpoints share the
                    // same platform.
                    if (_collabPlatform == null)
                    {
                        // Initalize and startup the platform.
                        _collabPlatform = new CollaborationPlatform(settings);

                        // Wire up a handler for the
                        // ApplicationEndpointOwnerDiscovered event.
                        _collabPlatform.RegisterForApplicationEndpointSettings(
                            this.Platform_ApplicationEndpointOwnerDiscovered);
                        // Initalize and startup the platform.
                        _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform);

                        if (_endpointInitCompletedEvent.WaitOne())
                        {
                            UCMASampleHelper.WriteLine("Found an application EP the Owner Uri is: "
                                                       + _applicationEndpoint.OwnerUri);
                        }
                        else
                        {
                            Console.WriteLine("Application endpoint was not established within the given time,"
                                              + " ending Sample.");
                            UCMASampleHelper.FinishSample();
                        }
                    }
                    else
                    {
                        Console.WriteLine("Collaboration platform already exists, ending Sample.");
                        UCMASampleHelper.FinishSample();
                    }
                }
                else
                {
                    Console.WriteLine("No application ID was specified by the user. Unable to create an"
                                      + " ApplicationEndpoint to use in the sample.");
                    UCMASampleHelper.FinishSample();
                }

                return(_applicationEndpoint);
            }
            catch (InvalidOperationException iOpEx)
            {
                // Invalid Operation Exception may be thrown if the data provided
                // to the BeginStartUp is called when the platform has already been
                // started or terminated.
                // TODO (Left to the reader): Error handling code.
                UCMASampleHelper.WriteException(iOpEx);
                return(_applicationEndpoint);
            }
        }