Example #1
0
        /// <summary>
        /// Forwards the call to a contact or phone number.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonForward_Click(object sender, EventArgs e)
        {
            //since forwarding needs a contact, will show a dialog to get user input
            SelectContactDialog contactDialog = new SelectContactDialog(client.ContactManager);

            contactDialog.ShowDialog();

            //if a contact is selected
            if (contactDialog.DialogResult == DialogResult.OK && contactDialog.Contact != null)
            {
                //transfers the call (both audio and video) to the specified contact
                AsyncCallback callback = new AsyncOperationHandler(avModality.EndForward).Callback;
                try
                {
                    avModality.BeginForward(contactDialog.Contact, callback, null);
                }
                catch (LyncClientException lyncClientException)
                {
                    Console.WriteLine(lyncClientException);
                }
                catch (SystemException systemException)
                {
                    if (LyncModelExceptionHelper.IsLyncException(systemException))
                    {
                        // Log the exception thrown by the Lync Model API.
                        Console.WriteLine("Error: " + systemException);
                    }
                    else
                    {
                        // Rethrow the SystemException which did not come from the Lync Model API.
                        throw;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Adds a participant to the conversation.
        /// </summary>
        private void buttonAddRosterContact_Click(object sender, EventArgs e)
        {
            //obtains the contact
            SelectContactDialog contactDialog = new SelectContactDialog(client.ContactManager);

            contactDialog.ShowDialog(this);

            //if a contact is selected
            if (contactDialog.DialogResult == DialogResult.OK && contactDialog.Contact != null)
            {
                //add a participant to the conversation
                try
                {
                    conversation.AddParticipant(contactDialog.Contact);
                }
                catch (LyncClientException lyncClientException)
                {
                    Console.WriteLine(lyncClientException);
                }
                catch (SystemException systemException)
                {
                    if (LyncModelExceptionHelper.IsLyncException(systemException))
                    {
                        // Log the exception thrown by the Lync Model API.
                        Console.WriteLine("Error: " + systemException);
                    }
                    else
                    {
                        // Rethrow the SystemException which did not come from the Lync Model API.
                        throw;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Transfers the call to a contact: AvModality.BeginTransfer()
        /// </summary>
        private void buttonTransfer_Click(object sender, EventArgs e)
        {
            //since transfering needs a contact, will show a dialog to get user input
            SelectContactDialog contactDialog = new SelectContactDialog(client.ContactManager);

            contactDialog.ShowDialog();

            //if a contact is selected
            if (contactDialog.DialogResult == DialogResult.OK)
            {
                //*****************************************************************************************
                // The argument TransferOptions dictates whether the transfer target is able to redirect the
                // call or not. If the option is TransferOptions.DisallowRedirection and the target does not
                // accept the call, it will return to this endpoint.
                //*****************************************************************************************

                // Declare a simple handler for the async callback before invoking Transfer...
                AsyncCallback transferCallback = ar =>
                {
                    try
                    {
                        ModalityState  state;
                        IList <string> properties;
                        avModality.EndTransfer(out state, out properties, ar);
                        Console.Out.WriteLine("Transfer state: " + state);
                    }
                    catch (Exception ex)
                    {
                        Console.Out.WriteLine(ex);
                    }
                };

                //transfers the call (both audio and video) to the specified contact
                try
                {
                    avModality.BeginTransfer(contactDialog.Contact, TransferOptions.None, transferCallback, null);
                }
                catch (LyncClientException lyncClientException)
                {
                    Console.WriteLine(lyncClientException);
                }
                catch (SystemException systemException)
                {
                    if (LyncModelExceptionHelper.IsLyncException(systemException))
                    {
                        // Log the exception thrown by the Lync Model API.
                        Console.WriteLine("Error: " + systemException);
                    }
                    else
                    {
                        // Rethrow the SystemException which did not come from the Lync Model API.
                        throw;
                    }
                }
            }
        }