We begin the same way we did last week, establish a link to the running Lync or Skype4b client.
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
Twitter - @droutledge @ndbridge
No comments:
Post a Comment
Any spam comments will be deleted and your user account will be disabled.