Export (0) Print
Expand All

How to: Share a whiteboard session

[This is preliminary documentation and is subject to change.]

Describes how to share a whiteboard collaboration session in a Microsoft Lync 2013 Preview conversation by using the Microsoft Lync 2013 Preview API.

This topic describes how to create a virtual whiteboard, upload a whiteboard to a conversation content bin, and then share the whiteboard in a conversation. The sample application shown in Figure 1 is a Windows Forms application that implements the Lync 2013 Preview API to let a user manage whiteboard collaboration in a conversation.

Important note Important

Whiteboard collaboration management is not supported in Lync UI suppression mode.

This topic discusses the following concepts in whiteboard sharing.

Figure 1 shows a sample conversation console application that lets a user manage virtual whiteboards on the sharing stage of a Microsoft Lync 2013 Preview conversation window.

Figure 1. Conversation whiteboard collaboration console.

Conversation whiteboard collaboration console

When a user selects the Project Plan whiteboard from the console shown in Figure 1, the whiteboard is displayed in a Lync 2013 Preview conversation window sharing stage as shown in Figure 2.

Figure 2. Whiteboard sharing in Lync 2013 conversation window.

Whiteboard sharing in Lync conversation window

Before the logic from this topic runs in your application, a conversation must be active with the conversation and you have registered an event callback method for the ContentSharingModalityActionAvailabilityChanged() event. The Microsoft.Lync.Model.Conversation.Sharing.ContentSharingModality in a connected state. For information about starting a conversation that hosts content sharing, see How to: Start content sharing conversations.

Namespace declarations example

Add the following namespace declarations to your application

using Microsoft.Lync.Model;
using Microsoft.Lync.Model.Group;
using Microsoft.Lync.Model.Conversation;
using Microsoft.Lync.Model.Conversation.Sharing;
using System.Collections.Generic;


Field declaration example

Add the following class field declarations to your application.

        /// <summary>
        /// Lync client platform. The entry point to the API
        /// </summary>
        LyncClient _LyncClient;

        /// <summary>
        /// Represents a Lync conversation
        /// </summary>
        Conversation _conversation;

When the ModalityAction.CreateShareableWhiteboardContent action is available, you can create and upload a new whiteboard.

Upload a whiteboard

  1. Verify that the whiteboard can be created by calling the Modality.CanInvoke method.

  2. Create the whiteboard by calling the ContentSharingModality.BeginCreateContent method.

  3. Upload the new whiteboard to the conversation by calling the ShareableContent.Upload method.

  4. Register for the ShareableContent.ActionAvailabilityChanged event on the new whiteboard object.

Important note Important

You must catch any of the three possible exceptions that can be raised when a user creates a new whiteboard. These exceptions are raised when the asynchronous operation is complete. If no exceptions are raised, you can upload the new whiteboard to the conversation by calling the ShareableContent.Upload method on the new whiteboard. When the new whiteboard is uploaded to the conversation, the ContentSharingModality.ContentAdded event is raised.

Create and upload a whiteboard example

The following example finishes first three steps of the previous procedure. The fourth step is completed in a following code example.

    if (((ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing]).CanInvoke(ModalityAction.CreateShareableWhiteboardContent))
    {
        string contentTitle = "Project Plan";
        ((ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing]).BeginCreateContent(ShareableContentType.Whiteboard, contentTitle, (ar) =>
            {
                try
                {
                    ShareableContent sContent;
                    sContent = ((ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing]).EndCreateContent(ar);
                    sContent.Upload();
                }
                catch (MaxContentsExceededException) { MessageBox.Show("You have reached the maximum number of content bin items"); }
                catch (ContentTitleExistException) { MessageBox.Show("Content title already exists"); }
                catch (ContentTitleInvalidException) { MessageBox.Show("Content title is not valid"); }
            } 
        , null);
    }

Register for the ShareableContent.ActionAvailabilityChanged event example

The following example registers event callback methods on the new SharingModality object events.

        /// <summary>
        /// Raised when an item is uploaded to the content bin
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _sharingModality_ContentAdded(object sender, ContentCollectionChangedEventArgs e)
        {
            e.Item.StateChanged += _ShareableContent_StateChanged;
            e.Item.ActionAvailabilityChanged += _ShareableContent_ActionAvailabilityChanged;
        }


Handle the ActionAvailabilityChanged event example

The following example enables or disables the content item sharing UI buttons when the availability of actions on the Microsoft.Lync.Model.Conversation.Sharing.ShareableContent object changes.

        /// <summary>
        /// Raised when the availability of an action on a ShareableContent object changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _ShareableContent_ActionAvailabilityChanged(object sender, ShareableContentActionAvailabilityChangedEventArgs e)
        {
            if ("Project Plan" == ((ShareableContent)sender).Title)
            {
                EnableDisableButtonDelegate d = new EnableDisableButtonDelegate(EnableDisableButton);
                switch (e.Action)
                {
                    case ShareableContentAction.Present:
                        this.Invoke(d, new object[] { PresentContent_Button, e.IsAvailable });
                        break;
                    case ShareableContentAction.StopPresenting:
                        this.Invoke(d, new object[] { StopPresentingContent_Button, e.IsAvailable });
                        break;
                }
            }
        }


To share a whiteboard, call the ShareableContent.Present method on the content object that you want to share. If other content is being presented, it is displaced on the content sharing stage by the content sharing object that you called the Present method on.

Share a whiteboard

  1. Iterate on the ContentSharingModality.ContentCollection property to find the Microsoft.Lync.Model.Conversation.Sharing.ShareableContent object whose ShareableContent.Title property matches the title that you want to share.

  2. Verify that the content can be presented by calling the ShareableContent.CanInvoke method.

  3. Share the content by calling the ShareableContent.Present method.

Code example

The following example presents the content item whose title is "Project Plan".

            //Iterate on content collection of conversation content sharing modality,
            //looking for the content whose title matches the string selected in the
            //list.
            foreach (ShareableContent sContent in ((ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing]).ContentCollection)
            {
                if (sContent.Title == "Project Plan")
                {
                    int hrReason;
                    if (sContent.CanInvoke(ShareableContentAction.Present, out hrReason))
                    {
                        _ShareableContent = sContent;
                        sContent.Present();
                    }
                    else
                    {
                        MessageBox.Show("Cannot present whiteboard: " + hrReason.ToString());
                    }
                    break;
                }
            }


To stop sharing a whiteboard, call the ShareableContent.StopPresenting method on the content object that you want to stop sharing.

Stop sharing a whiteboard

  1. Get the shared content by reading the ContentSharingModality.ActiveContent property on the conversation content sharing modality.

  2. Verify that sharing can be stopped for the content by calling the ShareableContent.CanInvoke method.

  3. Stop sharing the content by calling the ShareableContent.StopPresenting method.

Code example

The following example stops sharing the content item whose title is "Project Plan".


        ShareableContent sharedContent = ((ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing]).ActiveContent;
        int hrReason;
        if (sharedContent.CanInvoke(ShareableContentAction.StopPresenting, out hrReason))
        {
            sharedContent.StopPresenting();
        }
        else
        {
            MessageBox.Show("Cannot stop presenting " + _ShareableContent.Type.ToString() + ": " + hrReason.ToString());
        }


When all these tasks are completed, the state of Lync 2013 Preview API objects are as described in the following table.

Lync 2013 Preview API conversation objects

Object

Description

State

Microsoft.Lync.Model.LyncClient

Client platform API entry point.

ClientState.SignedIn

Microsoft.Lync.Model.Conversation.Conversation

The content sharing conversation.

ConversationState.Active

Microsoft.Lync.Model.Conversation.Sharing.ContentSharingModality

The conversation content sharing modality.

NoteNote
Each participant in the active conversation exposes a collection of modalities that include a content sharing modality. Each of these content sharing modality objects is also connected.

ModalityState.Connected

Microsoft.Lync.Model.Conversation.Sharing.ShareableContent

The whiteboard that is uploaded and shared in the conversation.

ShareableContentState.Active

NoteNote
If you are no longer sharing the whiteboard then the status is ShareableContentState.Online

Community Additions

Show:
© 2014 Microsoft