Cookie CSS

Saturday, August 29, 2015

Basic Call Control Using the Lync Client SDK X

Holy cow, I can't believe this series has reached part 10.  It really may be time to seriously consider writing an eBook on this subject.  Last week we looked at how to forward a ringing call to your voicemail endpoint.  This week we'll look at a similar process, forwarding a ringing call to another user.


We begin the same way we did last week, establish a link to the running Lync or Skype4b client.

lyncClient lc = LyncClient.GetClient();
1.  Get the conservation in question.
Conversation c = //your ringing conversation

2.  Find the contact you wish to forward the call to

Contact num = lc.ContactManager.GetContractByUri(ContactsURI);

3.  Forward the call

void ForwardCall(Conversation c, Contact num)
        {
            if (c == null)
                return;

           
            if (c.Modalities[ModalityTypes.AudioVideo].CanInvoke(ModalityAction.Forward))
            {

                List<string> _context = new List<string>();
                Object[] asyncState = { ModalityState.Forwarding, _context, c.Modalities[ModalityTypes.AudioVideo] };

                c.Modalities[ModalityTypes.AudioVideo].BeginForward(num, myar =>
                {

                    try
                    {

                        c.Modalities[ModalityTypes.AudioVideo].EndForward(myar);

                    }
                    catch (ArgumentException)
                    {
                        Console.WriteLine("Entered Uri is not valid " + num.Uri);
                    }
                    catch (ItemNotFoundException)
                    {
                        Console.WriteLine("Entered Uri could not be resolved to a Contact " + num.Uri);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                        string er;
                        er = "ForwardCall: Error Trapped in " + Dlib.ProgramSource + ".\r\n";
                        er = er + trace.GetFrame(0).GetMethod().Name + "\r\n" + ex.Message.ToString();
                        er = er + "Line: " + trace.GetFrame(0).GetFileLineNumber();
                        er = er + "Column: " + trace.GetFrame(0).GetFileColumnNumber();
                        Console.WriteLine(er);
                    }

                }, asyncState);
            }
        }

That will conclude this weeks blog post.  If you have any questions hit me up on twitter.

Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer  BridgeOC
Twitter - @droutledge @ndbridge


No comments:

Post a Comment

Any spam comments will be deleted and your user account will be disabled.