Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Hands-On Lab
Launching Contextual Conversations from the Lync Controls
Lab version: 1.0
Last updated: 12/17/2010
CONTENTS
OVERVIEW ............................................................................................................................................. 3 System Requirements 3
EXERCISE 1: INTEGRATE LAUNCH LINK AND DATA INTO A LYNC 2010 CONVERSATION ............ 3 Task 1 – Beginning the Exercise ........................................................................................................ 3
Task 2 – Registering the Package ...................................................................................................... 4
Task 3 – Setting Contextual Data ...................................................................................................... 5
Task 4 – Registering the Application ................................................................................................. 8
EXERCISE 2: EXTENDING THE CONVERSATION WINDOW WITH SILVERLIGHT .............................. 9 Task 1 – Beginning the Exercise ........................................................................................................ 9
Task 2 – Registering the Package .................................................................................................... 10
Task 3 – Adding the Silverlight Extension to the Conversation Window .......................................... 11
SUMMARY ............................................................................................................................................ 13
Overview
Lab Time: 45 minutes
Lab Folder: C:\%UC14TrainingKit%\Labs\3\Source\Before
The After folder contains the completed lab exercises.
Lab Overview: The Microsoft Lync 2010 Managed API provides several mechanisms for adding
contextual conversation functionality to applications. In this lab, you will see how to deploy contextual
application components to provide a rich context experience in a communications-enabled application.
In this lab, you will:
Register your application with Microsoft Lync 2010 so contextual conversation features will
beavailable to all participants in the conversation.
Start a contextual conversation that includes an application launch link and application data.
Extend the Lync 2010 conversation window with a Silverlight application that displays
application data.
System Requirements
You must have the following items to complete this lab:
Microsoft Visual Studio 2010
Microsoft Lync 2010
Microsoft Lync 2010 SDK – Lync Controls
Microsoft Lync 2010 Managed API
Two accounts (referred to as the primary and secondary lab users in this document),
provisioned for the Microsoft Lync Server 2010, that are able to successfully sign in to Lync
2010.
Exercise 1: Integrate Launch Link and
Data into a Lync 2010 Conversation
Task 1 – Beginning the Exercise
In this task, you will open the project and configure it to run with your accounts.
1. Navigate to Start >> All Programs >> Microsoft Visual Studio 2010.
2. Click on the Microsoft Visual Studio 2010 icon to start Visual Studio 2010.
3. Select File >> Open Project.
4. Navigate to the folder C:\%UC14TrainingKit%\Labs\3\Source\Before.
5. Open the AddingContexttoConversations.sln solution.
6. In Solution Explorer, right-click the LaunchLink project and select Set as Startup Project.
7. Open the LaunchLink project.
8. In Solution Explorer, open the App.config file.
9. Change the PrimaryLabUserId and SecondaryLabUserId values to the SIP URI of your primary
and secondary lab accounts.
10. Replace the ApplicatonGuid with a new Guid.
11. Select View >> Task List and select Comments from the menu.
12. Start a remote desktop session as the secondary lab user.
13. Return to the primary lab user’s session.
Generate a new Guid with the Guid Generator tool. Go to Tools >> Create Guid in the Visual Studio
2010 menu or go to Start >> All Programs >> Visual Studio 2010 >> Microsoft Windows SDK Tools >>
Guid Generator. Select option 4. Registry Format, click the New Guid button, click the Copy button
and paste that value into the App.config file.
Task 2 – Registering the Package
In this task, you will add the registry settings to deploy the contextual conversation components.
1. In Solution Explorer, open PackageRegistration_LaunchLink.reg.
2. Copy the new GUID from Task 1 into the
[HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\{<GUID>}]
value.
3. Change the Path entry to the path of LaunchLink.exe in the project’s output directory, i.e.
bin\Debug. When entering the Path, use “\\” instead of “\”.
4. Save the file.
5. Right-click the Launch Link project and select Open Folder in Windows Explorer.
6. Double click the .reg file to run it.
7. Open the Registry Editor by going to the Start menu and typing regedit.exe into the search
field.
8. Navigate to
HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\<GUID>.
a. This is the GUID from the .reg file.
9. Confirm that the settings match those in the .reg file.
10. Copy the .reg file to the clipboard and switch to the secondary lab user’s remote desktop
session.
11. Paste the file to the desktop and double click to run it and create the same registry settings on
the secondary lab user’s desktop.
If the secondary user does not have permission to view the solution, or is logged in to a different
computer, copy the solution over and modify the path in the .reg file to point to the local copy of
LaunchLink.exe.
Task 3 – Setting Contextual Data
In this task, you will add launch link contextual data to the Lync Controls.
1. Navigate to TODO: 3.1.1.
2. Add the following code after the TODO: 3.1.1 comment. This defines the contextual
information for the conversation.
C#
ConversationContextualInfo context = new ConversationContextualInfo();
context.Subject = selectedAccount.AccountName;
context.ApplicationId = _applicationGuid;
context.ApplicationData = "AccountId:" + selectedAccount.ID.ToString();
3. The Subject specifies the text displayed in the invite to join the conversation, the
ApplicationId specifies GUID of the registered application, and the ApplicationData
specifies the command line arguments when the application is run. This configures the
conversation window with a launch link for the application.
4. Navigate to TODO: 3.1.2.
5. Add the following code after the TODO: 3.1.2 comment. This sets the context of the
StartInstantMessagingButton and StartAudioCallButton controls to the object defined
previously.
C#
startInstantMessagingButton.ContextualInformation = context;
startAudioCallButton.ContextualInformation = context;
6. Navigate to TODO: 3.1.3
7. Add the following code after the TODO: 3.1.3 comment. This retrieves the
ConversationContextualInfo.ApplicationData conversation context from the command
line arguments used to launch the application from the LaunchLink.
C#
if (App.CommandLineArgs.Count > 0 && App.CommandLineArgs["AccountId"] !=
null)
{
LoadSelectedAccount(Convert.ToInt32(App.CommandLineArgs["AccountId"]));
}
8. Navigate to TODO: 3.1.4.
9. Add the following code after the TODO: 3.1.4 comment. This selects the account specified
in the command line arguments in the list of accounts.
C#
foreach (var account in _accounts)
{
if(account.ID == accountId)
{
accountsList.SelectedItem = account;
break;
}
}
10. Go to Start >> Start Without Debugging or press [Ctrl]+[F5] to start the application.
11. Select the Separate Parts Corporation account from the list.
12. Click the IM icon at the bottom of the window.
13. Type “Can you discuss this account?” into the conversation window and press the Enter key.
14. Switch to the secondary lab user’s remote desktop session and click the toast message to
receive the IM.
15. The toast message will display the name of the selected account.
16. Click on the link in the IM conversation window to launch the application.
17. The application is launch and the Separate Parts Corporation account is selected in the list of
accounts.
18. Close the application and all Lync 2010 conversation windows.
19. Return to the primary lab user’s remote desktop session.
Task 4 – Registering the Application
In this task, you will register the application so a contextual conversation can interact with a running
instance of the application.
1. Navigate to TODO: 3.1.5.
2. Add the following code after the TODO: 3.1.5 comment. This instantiates the
ApplicationRegistration object and allows the conversation window to interact with a
running application.
C#
private ApplicationRegistration _applicationRegistration;
3. Navigate to TODO: 3.1.6.
4. Add the following code after the TODO: 3.1.6 comment. This registers the application by
its GUID and name.
C#
_applicationRegistration = _lyncClient.CreateApplicationRegistration(
_applicationGuid,
_applicationName);
_applicationRegistration.AddRegistration();
5. Repeat steps 10–17 from Task 3 to confirm the application still works as it did in the
previous task.
6. In the secondary lab user’s session, close the IM window, but leave the application running.
7. Return to the primary lab user’s session and close the IM window.
8. Select the Central Discount Store account in the application.
9. Click on the IM icon to start another conversation.
10. Type a message and press the Enter key.
11. Switch to the secondary lab user’s session.
12. Click the link in the conversation window.
13. Verify that the application automatically selects the account selected in the primary lab
user’s session.
14. Close the IM windows and applications.
Exercise 2: Extending the Conversation
Window with Silverlight
Task 1 – Beginning the Exercise
In this task, you will open the project and configure it to run with your accounts.
1. Navigate to Start >> All Programs >> Microsoft Visual Studio 2010.
2. Click on the Microsoft Visual Studio 2010 icon to start Visual Studio 2010.
3. Select File >> Open Project.
4. Navigate to the folder C:\%UC14TrainingKit%\Labs\3\Source\Before.
5. Open the AddingContexttoConversations solution.
6. In Solution Explorer, right-click the LaunchLinkCWE project and select Set as Startup
Project.
7. Open the LaunchLinkCWE project.
8. In Solution Explorer, open the app.config file.
9. Change the PrimaryLabUserId and SecondaryLabUserId values to SIP URI of your primary
and secondary lab accounts.
10. Replace the ApplicatonGuid with a new GUID.
11. Select View >> Task List and select Comments from the menu.
12. Start a remote desktop session with the secondary lab user.
13. Add localhost to Internet Explorer’s list of Trusted sites.
a. Launch Internet Explorer.
b. Navigate to Tools >> Internet Options and select the Security tab.
c. Select Trusted sites and click the Sites button.
d. Uncheck the “Require server verification for all sites in this zone” box.
e. Add localhost to the list of Websites and click Close.
f. Click OK and close Internet Explorer.
14. Return to the primary lab user’s session.
Generate a new GUID with the GUID Generator tool. Go to Tools >> Create GUID in the Visual
Studio 2010 menu or go to Start >> All Programs >> Visual Studio 2010 >> Microsoft
Windows SDK Tools >> GUID Generator, select option 4, click the New GUID button, click
the Copy button and paste that value into the app.config file.
Task 2 – Registering the Package
In this task, you will add the application to the computer’s registry for the primary lab user.
1. In Solution Explorer, open PackageRegistration_LaunchLinkCWE.reg.
2. Copy the new GUID created in the last task into the registry path.
3. Change the Path entry to the path of LaunchLinkCWE.exe in the project’s output directory,
i.e. bin\Debug. When entering the Path, use “\\” instead of “\”.
4. Change the InternalURL and ExternalURL values to the URL of the Silverlight XAP:
a. Highlight the LaunchLinkCWE.Silverlight.Web project in the Solution Explorer window
and open its properties.
b. Click the Web tab.
c. Make note of the Port that Visual Studio’s Cassini web server will use to host this web
application. For this lab, we will use Visual Studio’s built in Cassini web server to host the
ASP.NET web application.
d. Open PackageRegistration_LaunchLinkCWE.reg.
e. Replace <PORT> in the value of InternalURL and ExternalURL with the port that Visual
Studio’s Cassini web server will use to host this web application.
5. Save the file.
6. Right-click the LaunchLinkCWE project and select Open in Windows Explorer.
7. Double click the .reg file to run it.
8. Open the Registry Editor by going to Start and typing regedit into the search field.
9. Navigate to
HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\<GUID>.
i. This is the GUID from the .reg file.
10. Check that the settings match those in the file.
11. Copy the .reg file to the clipboard and switch to the secondary lab user’s remote desktop
file session.
12. Paste the file to the desktop and double click to run it and create the same registry settings
on the secondary lab user’s desktop.
If the secondary user does not have permission to view the solution, or is logged in to a
different computer, copy the solution over and modify the path in the .reg file to point to the
local copy of LaunchLinkCWE.exe. The same applies to the URLs that point to the Default.aspx
file.
Make sure Cassini is running before trying to access the application. To start Cassini, set
LaunchLinkCWE.Silverlight.Web as your startup project. Then go to Start >> Start Without
Debugging or press [Ctrl]+[F5]. Once Cassini is running, close Internet Explorer and change
your startup project back to LaunchLinkCWE.
Task 3 – Adding the Silverlight Extension to the Conversation Window
In this task, we will add a Silverlight extension to a conversation window.
1. Navigate to TODO: 3.2.1.
2. Add the following code after the TODO: 3.2.1 comment. This defines the contextual
information and applies that contextual info in the two Lync conversation controls.
C#
ConversationContextualInfo context = new ConversationContextualInfo();
context.Subject = selectedAccount.AccountName;
context.ApplicationId = _applicationGuid;
context.ApplicationData = "AccountId:" + selectedAccount.ID.ToString();
startInstantMessagingButton.ContextualInformation = context;
startAudioCallButton.ContextualInformation = context;
3. Navigate to TODO: 3.2.2.
4. Add the following code after the TODO: 3.2.2 comment. This identifies the GUID of the
SilverLight application.
C#
string _applicationGuid = "{<enter your guid here>}";
Note: Change the _applicationGuid to match the value in the registry file.
5. Navigate to TODO: 3.2.3.
6. Add the following code after the TODO: 3.2.3 comment. This gets a reference to the
conversation hosting the Silverlight application. The conversation contains the context that
the application will receive and use.
C#
conversation = LyncClient.GetHostingConversation() as Conversation;
7. Navigate to TODO: 3.2.4.
8. Add the following code after the TODO: 3.2.4 comment. This gets the application data by
calling GetApplicationData on the conversation hosting the Silverlight application.
C#
_appData = conversation.GetApplicationData(_applicationGuid);
9. Navigate to TODO: 3.2.5.
10. Add the following code after the TODO: 3.2.5 comment. This uses the data that was passed
in the conversation’s contextual data to load the data for the selected account.
C#
int accountId = Convert.ToInt32(_appData.Split(new char[] { ':' })[1]);
Account account = _accounts.Where(a => a.ID == accountId).First();
this.accountName.Text = account.AccountName;
ordersList.ItemsSource = account.Orders;
11. Go to Start >> Start Without Debugging or press [Ctrl]+[F5] to start the application.
12. Select the Separate Parts Corporation account from the list.
13. Click the IM icon at the bottom of the window.
14. Type “Can you discuss this account?” into the conversation window and press the Enter
key.
15. Switch to the secondary lab user’s session and click the Toast message to receive the IM.
16. The invite should display the name of the account selected in the primary lab user’s
session.
17. Verify that the conversation window contains the Silverlight extension.
18. Click on the link in the conversation window.
19. Verify that it loads the LaunchLink application and selects the Separate Parts Corporation
account from the primary lab user’s session.
20. Close the IM windows and the application and return to the primary lab user’s session.
Summary
Adding context to conversations can streamline communications by immediately getting all conversation
participants on the same page. In this lab, you learned how to start an instant messaging conversation
that used contextual conversation components to launch an application and set its context, enabling
contextual collaboration between participants in the conversation. You also saw how to start an instant
messaging conversation that embedded contextual data in Silverlight application in the Lync 2010
conversation window