1. The consult call
A consult call is the call from you to the person the call is for, it occurs while the waiting caller is placed on hold. The code can look something like this.
string destination = "1234";
Conversation myco = MakeCallConsult(destination);
2. The supervised transfer
Once this call is dialed and connected you can as the caller at dn 1234 what they would like you do with the outside caller. If they want the call the supervised transfer procedure below works, where you pass the outside conversation first, and the consult call conversation last.
SupervisedTransfer(Outsideconv, null, TransferOptions.None, myco);
private void SupervisedTransfer(Conversation c, Contact num, TransferOptions topt, Conversation b)
{
if (c.Modalities[ModalityTypes.AudioVideo].CanInvoke(ModalityAction.ConsultAndTransfer))
{
List<string> _context = new List<string>();
Object[] asyncState = { ModalityState.Transferring, _context, c.Modalities[ModalityTypes.AudioVideo] };
c.Modalities[ModalityTypes.AudioVideo].BeginConsultativeTransfer(b, topt, myar =>
{
try
{
Object[] _asyncState = (Object[])myar.AsyncState;
ModalityState ms = (ModalityState)_asyncState[0];
IList<string> _contextProperties = (List<string>)_asyncState[1];
c.Modalities[ModalityTypes.AudioVideo].EndConsultativeTransfer(out ms, out _contextProperties, 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 = "SupervisedTransferCall: 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);
}
}
Once it reaches the EndConsultativeTransfer section you will be disconnected from the outside call and the original source and preferred destination user and now connected on the audio call.
That's a wrap for this week, next week we'll work are way further down the rabbit hole.
Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer BridgeOC
Twitter - @droutledge @ndbridge
Hi Doug, thanks for the brilliant blog posts on Lync. Do you have a sample running of the consultative transfer call, to share it? Thanks
ReplyDelete