Use the following methods in applications to send and update data in existing conversations.

Method

Description

Conversation.BeginSendInitialContext

BeginSendInitialContext is the setup method, call it first. This method will work for most scenarios, and most users need not go further. This method can be used more than once in a single conversation, for example if there is a change in subject and additional data is needed. Data limit is 2,000 characters.

Conversation.BeginSendContextData

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, but it can be re-used in an existing conversation as often as needed. Data limit is 64,000 characters.

BeginStartConversation(string, int, AsynCallback, object)

Use the BeginStartConversation method and and the values of the AutomationModalitySettings enumerator to add rich context to Microsoft Lync 2010 SDK conversations.

Sending and Updating Data in an Existing Conversation

Use the Conversation.BeginSendInitialContext method as shown in the following example.

  Copy imageCopy Code
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);

Use the Conversation.BeginSendContextData method as shown in the following example.

  Copy imageCopy Code
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

Use the BeginStartConversation method and the values of the AutomationModalitySettings enumerator to add rich context to Microsoft Lync 2010 SDK conversations. Also, use the Conversation.BeginSendInitialContext method. See the following sample code.

  Copy imageCopy Code
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 conversation is started.
_Automation.EndStartConversation(ar);

Sending a Context Link

To send a context link, use the ContextType.HyperLink enumeration as shown in the following example.

  Copy imageCopy Code
List<ContextType> context = new List<ContextType>();
List<object> data = new List<object>();
context.Add(ContextType.HyperLink);
data.Add("http://contoso.com");
IAsyncResult res = conversation.BeginSendContext(context, data,
SendContextCallback, null);

See Also

Other Resources