Send and Update Context in an Existing Conversation with Lync 2010 SDK
Use the following methods in Microsoft Lync 2010 SDK applications to send and update data in existing conversations.
Method |
Description |
---|---|
BeginSendInitialContext(IEnumerable<KeyValuePair<ContextType, Object>>, AsyncCallback, Object) |
BeginSendInitialContext is the setup method, call it first. This method works for most scenarios, and most users do not have to go further. This method can be used multiple times in a single conversation, for example, if there is a change in subject and additional data is needed. Data limit is 2,000 characters. |
BeginSendContextData(String, String, String, AsyncCallback, Object) |
Use BeginSendContextData for more advanced scenarios, such as implementing a command and response protocol, or exchanging large amounts of data. It can only be used after a session is established. However, it can be used again in an existing conversation as often as needed. Data limit is 64,000 characters. |
BeginStartConversation(String, Int32, AsyncCallback, Object) |
Use the BeginStartConversation method and the values of the AutomationModalitySettings enumerator to add rich context to Lync SDK conversations. |
Sending and Updating Data in an Existing Conversation
The following example shows how to use the Conversation.BeginSendInitialContext method.
Dictionary<ContextType, object> context = new Dictionary<ContextType, object>();
context.Add(ContextType.ApplicationId, "{d0722164-f660-470f-a933-e4853f215b77}");
context.Add(ContextType.ApplicationData, "Some data string");
IAsyncResult res = conversation.BeginSendInitialContext(context, null, null);
The following example implements the Conversation.BeginSendContextData method.
string appId = "{d0722164-f660-470f-a933-e4853f215b77}";
string appData = "Some additional data";
IAsyncResult res = conversation.BeginSendContextData(appId, "text/plain", appData, SendAdditionalContextCallback, null);
// Callback method
public void SendAdditionalContextCallback(IAsyncResult res)
{
conversation.EndSendAdditionalContextData(res);
}
Events
Use the Conversation object OnInitialContextReceived and OnInitialContextSent events to notify the application that the conversation received and sent data.
Adding Context to a Conversation
The following example shows how to use the BeginStartConversation method and the values of the AutomationModalitySettings enumerator to add rich context to Lync SDK conversations. Also, use the Conversation.BeginSendInitialContext method.
Dictionary<AutomationModalitySettings, object> _ModalitySettings = new Dictionary<AutomationModalitySettings, object>();
// Add the process ID to the modality settings for the conversation.
_ModalitySettings.Add(ApplicationId, "{40499119-4B60-45a6-9A7A-DC7A384D5670}";
// Add application data.
_ModalitySettings.Add(AutomationModalitySettings.ApplicationData, "some application data with you.");
// Declare the string array.
string[] invitees = {″elise@contoso.com"};
IAsyncResult ar = _Automation.BeginStartConversation(
_ChosenMode
, invitees
, _ModalitySettings
, null
, null);
// Block main thread until the conversation starts.
_Automation.EndStartConversation(ar);
Sending a Context Link
To send a context link, use the ContextType.HyperLink enumeration.
Dictionary<ContextType, object> context = new Dictionary<ContextType, object>();
context.Add(ContextType.HyperLink, "https://contoso.com");
IAsyncResult res = conversation.BeginSendInitialContext(context, SendContextCallback, null);
See Also
Other Resources
Lync Extensibility API Contextual Conversations (Lync 2010 SDK)