Consume Data and Handle Events in a Contextual Conversation

[This is preliminary documentation and is subject to change.]

Use Microsoft .NET Framework code and the Microsoft Lync 2013 Preview SDK to consume contextual data and handle events in a Microsoft Lync 2013 Preview conversation.

Use Conversation object methods and events to send and access contextual data in a Lync 2013 Preview conversation.

Sending Data

Use the BeginSendInitialContext and BeginSendContextData methods to send and update data in existing conversations. For more information, see Send and Update Context in an Existing Conversation.

Accessing Data

On the receiver side, use the InitialContextReceived event to access data.

public void OnInitialContextReceived(Microsoft.Lync.Model.Conversation.Conversation eventSource, Microsoft.Lync.Model.Conversation.ContextEventArgs eventData)
        {
            try
            {
                string appId = eventData.ApplicationId;
                string appData = eventData.ApplicationData;
                Log(Color.Blue, string.Format(
                    "ContextualConversation_OnContextReceived AppId={0}, AppData={1}",
                    appId, appData
                    ));
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }

On the sender side, use the InitialContextSent event to access data.

public void OnInitialContextSent(Microsoft.Lync.Model.Conversation.Conversation eventSource, Microsoft.Lync.Model.Conversation.ContextEventArgs eventData)
        {
            try
            {
                string appId = eventData.ApplicationId;
                string appData = eventData.ApplicationData;
                Log(Color.Blue, string.Format(
                    "ContextualConversation_OnContextSent AppId={0}, AppData={1}",
                    appId, appData
                    ));
                string sourceAppData = eventSource.GetApplicationData(appId);
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }

Use the GetApplicationData method on the Conversation object to access the most recent initial context. The most recent initial context is what the user has just sent or received using the BeginSendInitialData or BeginStartConversation methods. GetApplicationData returns no other context sent or received through BeginSendContextData.

Use LaunchLink to Access Application Data

Each launch link has data embedded in the start URL. Clicking the link starts the application together with the corresponding application data and raises the ConversationContextLinkClicked event. LaunchLink appears in the conversation history when a user sends or receives a contextual conversation tied to a contextual application whose registration data contains a Path value. Clicking the link executes the Path+Parameters values. If there is a %AppData% parameter in the Parameters value it will be replaced with the data embedded in the LaunchLink. The click also raises the LinkClicked event which delivers the application data to the application if it is running. If the application is not running the event is missed.

public void OnConversationContextLinkClicked(uc.Conversation eventSource, uc.ContextEventData eventData)
        {
            try
            {
                Log(Color.Blue, string.Format("ContextualConversation_OnLaunchLinkClicked AppId={0}, AppData={1}",
                    eventData.ApplicationId, eventData.ApplicationData
                    ));
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }

Use the ConversationAdded() event for conversation handling. ConversationAdded provides access to Conversation and ConversationWindow objects. To review example code that shows how to use the ConversationAdded event, see How to: Start an IM Conversation.

Community Additions

Show:
© 2014 Microsoft