Microsoft Lync has 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 them.

Accessing the inner endpoint

Posted: May 23rd, 2013 | Author: | Filed under: UCMA 4.0 | Tags: | 1 Comment »

Although the title sounds very philosophical, I’m not going to talk in this post about an inward journey of discovery for your application endpoints. Instead, I want to talk about a way to access some parts of the signaling layer – the lower-level part of UCMA that allows you to work directly with SIP messages – from the collaboration layer, where most UCMA development takes place.

Recently I’ve gotten a lot of questions about how you can make UCMA do very specific things with SIP messages, like changing the way the SDP media offers are constructed. In many cases, the answer is, unfortunately, that you can’t have your cake and eat it too: if you want to take advantage of the relative simplicity of the collaboration layer, with high-level classes like AudioVideoCall, ConferenceSession, and RemotePresenceView, rather than building SIP messages from scratch, then you have to give up some control over what goes into the SIP messages that get generated. But there are a few places where you can have a little bit of extra control without giving up the collaboration layer completely. One of those is the various Options classes, where you can add extra SIP headers to many types of outgoing messages.

Another one that many people are unaware of is the InnerEndpoint property on the ApplicationEndpoint and UserEndpoint classes. This is a sort of secret trap-door into the signaling layer. It gives you access to the counterpart of UserEndpoint or ApplicationEndpoint in the Microsoft.Rtc.Signaling namespace: RealTimeEndpoint. Using RealTimeEndpoint, you can create and handle SIP dialogs at a much lower level than is possible with the collaboration layer.

For example, you can do something like this to send a SIP INVITE with your own, customized SDP body:

SignalingSession session = new SignalingSession(_endpoint.InnerEndpoint,
    new RealTimeAddress("sip:mgreenlee@claritycontest.com"));
session.OfferAnswerNegotiation = _customOfferAnswer;

try
{
    session.BeginEstablish(establishAsyncResult =>
    {
        try
        {
            session.EndEstablish(establishAsyncResult);
        }
        catch (RealTimeException ex)
        {
            Console.WriteLine(ex);
        }
    },
    null);
}
catch (InvalidOperationException ex)
{
    Console.WriteLine(ex);
}

In this example, _customOfferAnswer would contain an instance of a class that implements IOfferAnswer, to define how the media negotiation should be handled. I’ll talk more about IOfferAnswer and how to implement it in a future blog post, but the point is that you can use the classes in the Collaboration namespace to handle most functions of your application while still falling back on the Signaling namespace for more detailed work.

You can also hook up an event handler to handle incoming SIP messages:

_userEndpoint.InnerEndpoint.SessionReceived += OnInnerEndpointSessionReceived;

In any case, it’s good to be aware of the InnerEndpoint property for cases where you need to drop down to the signaling layer for specific messages.


One Comment on “Accessing the inner endpoint”

  1. 1 Navkar said at 8:45 am on August 5th, 2014:

    Hi Michael,

    I am doing something similar in my application – I need the capability to customize the SDP body (negotiation) and also want to transfer media over the same session once the SDP is negotiated (need to hook both ends in an audio call). Is it possible to transfer media (audio) while using SignalingSession object? Or can you suggest any alternative way to achieve the same.


Leave a Reply

  • Note: Comment moderation is in use because of excessive spam. Your comment may not appear immediately.

  •