Use .NET code and the Microsoft Lync 2010 SDK to consume contextual data and handle events in a Microsoft Lync 2010 conversation.
Send and Access Contextual Data
Use
Sending Data
Use the BeginSendInitialContext and BeginSendContextData methods to send and update data in existing conversations. For more information, see the topic Send and Update Context in an Existing Conversation .
Accessing Data
On the receiver side, use the
Copy Code | |
---|---|
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
Copy Code | |
---|---|
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 does not return any subsequent context sent or received via BeginSendContextData .
Use LaunchLink to Access Application Data
Each launch link has data embedded in the launch URL. Clicking
the link launches the application with the corresponding
application data and fires the
Copy Code | |
---|---|
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); } } |
Handle the ConversationAdded Event
Use the
ConversationAdded
()
()
()
()
event for conversation handling. The ConversationAdded event
provides access to