Share via


IUccSession Interface

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Encapsulates a communication and collaboration session.

Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)

Syntax

'Declaration
Public Interface IUccSession
    Inherits IUnknown
public interface IUccSession : IUnknown
public interface class IUccSession : IUnknown
public interface IUccSession extends IUnknown
public interface IUccSession extends IUnknown

Remarks

A communication and collaboration session is characterized by a group of participants connected with each other for the purpose of exchanging information and sharing data. In UCC API, such a session can be transmission-based (also known as a non-conference session) or transmission-free (also known as a conference session). Examples of a transmission-based sessions include instant messaging or audio and video sessions. A conference typically also contains IM, AV, or other transmission-based sessions.

This interface is the base upon which all specific session types are derived. Session manager (OnIncomingSession, OnOutgoingSession) and session events typically provide an IUccSession instance that can be cast to the appropriate session derived interface to expose functionality essential to the type of session in question. Another way to obtain a new instance of IUccSession is to call CreateSession on an instance of IUccSessionManager.

Win32 COM/C++ Syntax

interface IUccSession : IUnknown

Example

Originating an New Session

A client can obtain a new IUccSession instance from a session manager instance by calling CreateSession on the session manager. This example obtains a session in this way. In addition, the example creates an instance of UccContext, adds a named property to it, and passes it into CreateSession as the session context of the new session.

Important

If your application is to interoperate with Microsoft Office Communicator, you must add a unique conversation ID to any new session you create and invite remote participants to. The example below creates a GUID string and adds it as a property to a new session and assigns a property ID of 10000.

/// <summary>
/// Session constructor. Creates new IUccSession of the specified type
/// </summary>
/// <param name="sessionType">UCC_SESSION_TYPE: type of session to create</param>
/// <param name="sm">session manager obtained from registered endpoint</param>
public session(
    UCC_SESSION_TYPE sessionType, 
    IUccSessionManager sm,
)
{
    //new context object
    UccContext sessionContext = new UccContext();

    sessionContext.AddNamedProperty(
        "SessionTitle", 
        "IM Session");

    striing _ConversationGUID = System.Guid.NewGuid().ToString();
    sessionContext.AddProperty(10000, _ConversationGUID);

    //create IUccSession and store ref in private class field
    this._session = sm.CreateSession(
            sessionType,
            sessionContext);
    //advise for session events
    UCC_Advise<_IUccSessionEvents>(this._session, this);

}

Receiving a New Incoming Session

An application must handle events raised by an instance of IUccSessionManager. Specifically, the OnIncomingSession event provides the application with a new instance of IUccSession.

/// <summary>
/// handles session invitations by displaying a dialog for
/// local user advising user of invitation and providing a mechanism
/// for the user to respond to the invitation
/// </summary>
/// <param name="pEventSource"></param>
/// <param name="pEventData"></param>
void _IUccSessionManagerEvents.OnIncomingSession(
    IUccEndpoint pEventSource,
    UccIncomingSessionEvent pEventData)
{
    string conversationID = string.Empty;
    if (pEventData.Session.Context.IsPropertySet(10000) == true)
    {
        conversationID = pEventData.Session.Context.get_Property(10000).StringValue;
    }
    switch (pEventData.Session.Type)
    {
        case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
            IUccInstantMessagingSession imSession = pEventData.Session as IUccInstantMessagingSession;
            break;
        case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
            IUccAudioVideoSession avSession = pEventData.Session as IUccAudioVideoSession;
            break;
        case UCC_SESSION_TYPE.UCCST_CONFERENCE:
            IUccConferenceSession confSession = pEventData.Session as IUccConferenceSession;
            break;
       case UCC_SESSION_TYPE.UCCST_APPLICATION:
            break;
    }
    pEventData.Accept();
    //advise for session events
    UCC_Advise<_IUccSessionEvents>(pEventData.session, this);
}

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2000 with Service Pack 4, Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

IUccSession Members
Microsoft.Office.Interop.UccApi Namespace

Other Resources

Code Listing: Basic Event Registration and Other Helper Methods in C#