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.

Call forwarding, UCMA, and “derived conversations”

Posted: January 25th, 2012 | Author: | Filed under: UCMA 3.0 | Tags: , , , , | 2 Comments »

If you have a UCMA application that communicates with users via both IM and audio in the same conversation, you may one day be caught off guard by the following exception:

Microsoft.Rtc.Signaling.OperationFailureException: Application must register 
for ConversationChanged event when a call is moved to a derived conversation.

Specifically, this exception occurs if you try to add audio to a conversation that currently only has instant messaging and/or application sharing, and the remote party redirects the audio call to a PSTN phone; maybe because they don’t have headphones plugged in, or because they are on a wireless network which has been causing poor audio quality, or even because they are logged in on a client that doesn’t support audio.

What’s happening here is that the audio call that is part of the conversation is being routed to a PSTN phone, through the Mediation Server, instead of the original destination user. Because of this, the call is split off from the original Conversation object and is moved to a new, “derived” conversation, with a new conversation ID. If you look at the original Conversation object (the one that the IM call belonged to), you won’t see an AudioVideoCall, nor will you see the PSTN phone as a remote participant. At this point, you have no way to control the new audio call with the PSTN phone. Basically, UCMA tries to save you from yourself by insisting that you hook up an event handler to get the details of the new, derived Conversation. The event you need is Call.ConversationChanged.

To be notified when a derived conversation like this is created, subscribe to the ConversationChanged event on the new AudioVideoCall, like so:

avCall.ConversationChanged +=
    new EventHandler<ConversationChangedEventArgs>(OnAvCallConversationChanged);

In this event handler, you can do something useful with the new Conversation object, hopefully something more useful than just dumping the details to the console, as I’m doing here:

void OnAvCallConversationChanged(object sender,
    ConversationChangedEventArgs e)
{
    Console.WriteLine("Call moved to derived conversation! Old ID: {0}. New ID: {1}. Reason: {2}.",
        e.PreviousConversation.Id, e.NewConversation.Id, e.Reason);
}

This eliminates the exception and allows you to keep control of the audio call after it is redirected.


2 Comments on “Call forwarding, UCMA, and “derived conversations””

  1. 1 greiginsydney said at 12:33 am on February 25th, 2012:

    Hi Michael,

    I’m working on a client-side API project and am struggling to determine the conversation ID so that I can then update its subject.

    I’m in an IM handler, and my best attempts at finding the conversation result in “Unable to cast object of type ‘Microsoft.Lync.Model.Conversation.InstantMessageModality’ to type ‘Microsoft.Lync.Model.Conversation’.

    Do you know if what I’m trying to do is possible (and how)? So far I’ve drawn a blank.

    Thanks,

    Greig.

  2. 2 Michael said at 9:09 pm on February 26th, 2012:

    Greig – I’m not totally clear on the scenario. Is it that you have a handle to an incoming IM call in your application and you want to change the subject of that IM call?
    Is there any code you could post (or email to me) so I have some context? Thanks!


Leave a Reply

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

  •