Bridge Communications

Saturday, August 15, 2015

Basic Call Control Using the Lync Client SDK VIII

As we begin part 8 of this Lync client SDK call control, I think we have officially eclipsed the number of Rocky sequels.  To that end, I think I may combine the content of this series, plus a lot more into a free tech-net eBook.

Last week we learned how to transfer a call to a user's cellphone, when that user is someone the Lync client knows about, and will return their contact containing a sip uri.  So today's blog will focus on a similar task, calling a user's mobile phone, when Lync knows about their sip uri.  To begin we start just like last week.



1.  Get the Contact

Let's get a contact object first by doing a search

Conversation c;  //the conversation to transfer
Contact num = LyncClient.ContactManager.GetContactByUri(string search);

 public static void BlindTransferCallCell(Conversation c, Contact num, TransferOptions topt)
        {

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

2.  Browse the Contact's endpoints


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

                ContactEndpoint ce = null;

                foreach (ContactEndpoint cone in (List<object>)num.GetContactInformation(ContactInformationType.ContactEndpoints))
                {
                    if (cone.Type == ContactEndpointType.MobilePhone)
                    {
                        ce = cone;
                    }
}

List<string> participants = new List<string>();

string myrui = ce.Uri;

participants.Add(myrui);

3.  Call the mobile phone endpoint

LyncClient.GetAutomation().BeginStartConversation(AutomationModalities.Audio, participants, null, (ar) =>
                {
                    try
                    {
                        ConversationWindow newWindow = LyncClient.GetAutomation().EndStartConversation(ar);
                    }
                    catch (OperationException oe) { Dlib.report_error("Operation exception on start conversation " + oe.Message); };
                },
                        null);

The takeaway here is when we are tying to transfer a call to a specific contact's number, not the sip uri, we need to transfer to the ContactEndpoint object instead of the Contact.

Thanks for tuning in and I will see you next week.

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.