Use Microsoft Lync 2010 SDK to add communications and collaboration functionality to your application. With Lync SDK, you can add Microsoft Lync 2010 features to an existing business application, or create a custom client that includes Microsoft Lync 2010 features. In either case, Lync 2010 must be a running process on the client computer that hosts a Microsoft Lync 2010 API application.
To add Lync 2010 features to an application, you drag and drop XAML controls from the Lync SDK into a Microsoft Windows Presentation Foundation (WPF) or Microsoft Silverlight application. For more advanced scenarios, use a .NET Framework language to incorporate Lync 2010 API features into your application.
Lync 2010 API is commonly used to start a new conversation within your custom application, after which you'll participate in that conversation using the Lync 2010 conversation window. You can also start and participate in a conversation within your custom application without displaying the Lync 2010 conversation window. Lync 2010 API can also be used to generate a contact list within your custom application using data obtained from Lync 2010.
Lync Controls
You can drag and drop Microsoft Lync Controls into existing business applications to add Lync 2010 functions and user interface. Each Lync Control provides a specific feature like search, presence, instant messaging (IM) calls, and audio calls. The appearance of each control replicates the Lync 2010 UI for that feature. Use a single control or multiple controls. The programming style is primarily XAML text, but you can also use C# in the code-behind file to access the Lync 2010 API and .NET Framework. For more information, see Lync Controls .
Lync Controls Application Scenarios
-
Drag and drop the PresenceIndicator control into each application, then set property values to configure how the control displays presence and contact information.
-
Add Lync 2010 functionality to Silverlight 4 browser applications.
-
Add Lync 2010 capabilities to .NET Framework applications using WPF.
Lync Controls Code Example
The following XAML text displays a PresenceIndicator control in a Lync Controls application. For more information, see Walkthrough: Presence Hello World .
XAML | Copy Code |
---|---|
<Window x:Class="myWpfApplication.UCWindow1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:Microsoft.Lync.Controls;assembly=Microsoft.Lync.Controls" Title="UCWindow1" Height="Auto" Width="Auto"> <Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <controls:PresenceIndicator x:Name="Presence" Source="sip:john@contoso.com" PhotoDisplayMode="Large" /> <TextBlock Text="{Binding DisplayName, ElementName=Presence}" Margin="4,0,0,0" VerticalAlignment="Center" /> </StackPanel> </Grid> </Window> |
Lync API
Use Lync 2010 API to launch and automate the Lync 2010 UI in your business application. Use Lync Controls to integrate specific features like presence, contact cards, or search, in a business application.
Lync API Application Scenarios
-
Start an instant messaging or audio conversation from a custom application.
-
Join or start a conference.
-
Add a new contact to your contact list.
Start Conversation Code Example
The following example starts an IM conversation using Lync 2010 API in Lync SDK. For more information, see Walkthrough: Start an Instant Message Conversation .
C# | Copy Code |
---|---|
public Form1() { InitializeComponent(); // Create the major API automation object. Automation myUIAuto = LyncClient.GetAutomation(); // Create a generic List object to contain a contact URI. // Ensure that a valid URI is added. List<string> inviteeList = new List<string>(); inviteeList.Add("elise@contoso.com"); // Create a generic Dictionary object to contain context objects. Dictionary<AutomationModalitySettings, object> myContextObjects = new Dictionary<AutomationModalitySettings, object>(); myContextObjects.Add(AutomationModalitySettings.FirstInstantMessage, "hello"); myContextObjects.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); // Start the conversation. IAsyncResult ar = myUIAuto.BeginStartConversation(AutomationModalities.InstantMessage, inviteeList, myContextObjects, null, null); myUIAuto.EndStartConversation(ar); } |
Advanced Application Scenarios
Use Lync 2010 API to add Lync 2010 functionality to new or existing .NET Framework applications and suppress the Lync 2010 UI. Lync SDK UI Automation automates the Lync 2010 interface, and Lync Controls add separate pieces of Lync 2010 functionality and UI as XAML controls. For more information, see Lync 2010 API .
The only UI element that Lync 2010 API exposes is the
Before you develop applications with Lync 2010 API, you should be familiar with the .NET Framework asynchronous programming pattern. You will write event handling methods and asynchronous callback methods to catch the results of operations and notifications of new and changed information from Lync Server 2010.
Lync API Application Scenarios
-
Contact management, availability publication and contact information, fill group and contact lists, search for groups and contacts, query contact availability and contact information.
-
Start or join IM, audio, and video conversations, add conversation participants, park and reactivate conversations, schedule and join conferences.
Lync API Code Example
The following example collects contact information. For more information, see Walkthrough: Display a Contact Card .
C# | Copy Code |
---|---|
private void ContactCardForm_Load(object sender, EventArgs e) { Contact myContact = sender as Contact; if (myContact != null) { this.Text = "Contact: " + myContact.GetContactInformation(ContactInformationType.Name).ToString(); lbl_EmailValue.Text = myContact.GetContactInformation(ContactInformationType.PrimaryEmail).ToString(); List<object> contactPhones = null; contactPhones = (List<object>) myContact.GetContactInformation(ContactInformationType.CollaborationEndpoints); foreach (object o in contactPhones) { CollaborationEndpoint collabEndpoint = o as CollaborationEndpoint; switch (collabEndpoint.Type) { case CollaborationEndpointType.Home: lbl_HomeValue.Text = collabEndpoint.DisplayString; break; case CollaborationEndpointType.Mobile: lbl_MobileValue.Text = collabEndpoint.DisplayString; break; case CollaborationEndpointType.Work: lbl_WorkValue.Text = collabEndpoint.DisplayString; break; } } lbl_TitleValue.Text = myContact.GetContactInformation(ContactInformationType.Title).ToString(); lbl_OfficeValue.Text = myContact.GetContactInformation(ContactInformationType.Office).ToString(); } } |
The following example signs in to Lync Server 2010 and handles the asynchronous results of a sign in request. For more information, see Walkthrough: Sign In to Lync .
C# | Copy Code |
---|---|
/// <summary> /// Method to sign in to Lync /// </summary> /// <param name="UserUri">string. Uri of user.</param> /// <param name="Domain">string. User name and Domain of user.</param> /// <param name="Password">string. Password of user</param> public void SignIn(string UserUri, string UserNameDomain, string Password) { LyncClient.GetClient().ClientStateChanged += myClient_ClientStateChanged; try { IAsyncResult ar = LyncClient.GetClient().BeginSignIn( UserUri, UserNameDomain, Password, null, null); LyncClient.GetClient().EndSignIn(ar); } catch (NotInitializedException) { MessageBox.Show("Lync is not initialized"); } } /// <summary> /// Handles LyncClient state change events. /// </summary> /// <param name="source">LyncClient. Client source of events.</param> /// <param name="data">ClientStateChangedEventArgs. State change data.</param> void myClient_ClientStateChanged(object source, ClientStateChangedEventArgs data) { if (data.NewState == ClientState.SignedIn) { MessageBox.Show("Signed in"); } if (data.NewState == ClientState.SignedOut) { MessageBox.Show("Signed out"); } if (data.NewState == ClientState.ShuttingDown ) { MessageBox.Show("Client is shutting down"); } } |