Microsoft Lync and Skype for Business have a rich set of .NET APIs which make it easy to extend the platform and integrate it with other applications. This blog helps explain how to use those APIs.

Some (paper) resources for Unified Communications development

Posted: May 12th, 2009 | Author: | Filed under: OCS Development | No Comments »

I am at TechEd this week, where we are announcing our new presence-powered real-time expert finder, Clarity Connect.

I wanted to point out two books that are great resources if you are doing any kind of development with the Microsoft Unified Communications platform.

The first is the Office Communications Server 2007 R2 Resource Kit. This book focuses on the structure and configuration of Office Communications Server, and is a good read if you want to get a comprehensive idea of how OCS works, which can be very helpful for development.

The second is Programming for Unified Communications, which is due to be released very soon. This book actually delves into development with the UC APIs, and should be an indispensible resource once it comes out.

The OCS Resource Kit book is also on Twitter — you can get bits and pieces of OCS info at http://twitter.com/DrRez.


Escalating an AudioVideoCall to a conference in UCMA 2.0

Posted: May 8th, 2009 | Author: | Filed under: OCS Development, UCMA 2.0 | 4 Comments »

If you’ve ever tried to escalate an AudioVideoCall to a conference, you will know that it isn’t the smooth, carefree experience that the words “conference escalation” call to mind. It has its pitfalls. Take a look at the following code:

private void CreateCallAndEscalate()
{
     // Create a conversation and a call.
     _conversation = new Conversation(_endpoint);
     _call = new AudioVideoCall(_conversation);
     _call.BeginEstablish(_yourSipUri, null, CallEstablishCompleted, null);
}

private void CallEstablishCompleted(IAsyncResult result)
{
     _call.EndEstablish(result);
     _conversation.ConferenceSession.BeginJoin(JoinCompleted, null);
}

private void JoinCompleted(IAsyncResult result)
{
     _conversation.ConferenceSession.EndJoin(result);

     try
     {
          _conversation.BeginEscalateToConference(EscalateCompleted, null);
     }
     catch (InvalidOperationException ex)
     {
          Console.WriteLine("Escalate failed:");
          Console.WriteLine(ex.ToString());
     }
}

private void EscalateCompleted(IAsyncResult result)
{
     try
     {
          _conversation.EndEscalateToConference(result);
     }
     catch (RealTimeException ex)
     {
          Console.WriteLine("Escalate failed:");
          Console.WriteLine(ex.ToString());
     }
}

At first glance, you might expect this code to cheerfully bump your AudioVideoCall up into the ad hoc conference and frolic off into the sunset. But no such luck. Run it, and you will be furnished with the following exception message:

Microsoft.Rtc.Signaling.OperationFailureException: The EscalateToConferenceAsyncResult operation has failed with message: “Call cannot escalate to conference, mediaProvider does not support escalation”. See the InnerException and FailureReason properties as well as the logs for additional information.  —> System.InvalidOperationException: Call cannot escalate to conference, mediaProvider does not support escalation  at Microsoft.Rtc.Collaboration.Call.BeginEscalate(McuSession mcuSession,AsyncCallback userCallback,Object state)

To make a long story short, the media provider for AudioVideoCalls doesn’t have built-in support for escalation to a conference. Thankfully, there IS a way to get an existing two-party call into an ad hoc conference. The ConferenceSession object that belongs to the Conversation in turn has its own AudioVideoMcuSession. You can call the BeginTransfer method on the AudioVideoMcuSession to transfer an existing two-party call to the MCU, effectively bringing it into the conference. The new JoinCompleted method would look something like this:

private void JoinCompleted(IAsyncResult result)
{
     _conversation.ConferenceSession.EndJoin(result);
     try
     {
          _conversation.ConferenceSession.AudioVideoMcuSession.BeginTransfer(
               _call, null, McuTransferCompleted, null);
     }
     catch (InvalidOperationException ex)
     {
          Console.WriteLine("MCU transfer failed:");
          Console.WriteLine(ex.ToString());
     }
}

You also need a callback method:

private void McuTransferCompleted(IAsyncResult result)
{
     try
     {
          _conversation.ConferenceSession.AudioVideoMcuSession.EndTransfer(
              result);
     }
     catch (RealTimeException ex)
     {
          Console.WriteLine("MCU transfer failed:");
          Console.WriteLine(ex.ToString());
     }
}

When you run this code (you’ll need to do the extra work of setting up a CollaborationPlatform and endpoint and so forth) it will look very much like the application is placing a call and then escalating it to a conference. For a lot of situations (such as accepting incoming two-party calls and then bringing them into a conference) this will fit the bill perfectly well.

Feel free to email me if you have questions about this or if you’d like the code for the full sample application.