Export (0) Print
Expand All

IUccSessionManager.CreateSession Method

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.

Creates a communication and collaboration session.

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

IUccSession CreateSession (
	UCC_SESSION_TYPE enSessionType,
	UccContext pContext
)
IUccSession CreateSession (
	UCC_SESSION_TYPE enSessionType, 
	UccContext pContext
)
function CreateSession (
	enSessionType : UCC_SESSION_TYPE, 
	pContext : UccContext
) : IUccSession

Parameters

enSessionType

A value of the UCC_SESSION_TYPE type. This specifies the type of the to-be-created session.

pContext

A value of the IUccContext* (UccContext, for a .NET application) type. This specifies the metadata associated with the to-be-created session.

A new instance of context is obtained by calling the constructor of the UccContext class. to get the IUccContext instance. Add appropriate metadata to the context as a collection of name-value pairs.

Return Value

A value of the IUccSession** (IUccSession, for a .NET application) type. A successful call returns the specified session object.

A communication and collaboration session can be either transmission-based or transmission-free. Transmission-based sessions include instant messaging (IM) sessions or audio and video (AV) sessions. A transmission-free session refers to a conference session. A conference typically consists of a conference session plus one or more transmission-based sessions. The resultant session object refers to a session of the specified session type (enSessionType). This session object also implements the corresponding type-specific session interface. The type-specific session interface and the IUccSession interface can be queried from each other.

If you intend your custom client to interoperate with Microsoft Office Communicator, you must create a unique conversation ID for any session you create. The conversation ID is added to the outgoing session invitation when you add a specific property to the operation context passed to CreateSession. You must assign a property ID of 10000 to the conversation ID property added to your operation context.

Win32 COM/C++ Syntax

HRESULT CreateSession
(
   UCC_SESSION_TYPE enSessionType,
   IUccContext* pContext,
   IUccSession** ppSession
);
Cc703153.note(en-us,office.12).gifNote:
In a Win32 application, the return value of a method or property is always an HRESULT value indicating the status of the call to the interface member. Any result of the operation is returned as a parameter marked with the [out, retval] attribute. In contrast, in a .NET application the HRESULT value indicating an error condition is returned as a COM exception and the [out, retval] parameter becomes the return value. For the UCC API-defined HRESULT values, see Trace and Handle Errors in Unified Communications Client API.

The following example constructor is drawn from an application class that wraps an IUccSession instance (this._session). The constructor accepts the UCC_SESSION_TYPE enumeration, a session manager, context key string, and context value.

/// <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>
/// <param name="pContextKey">session named context key</param>
/// <param name="pContext">session named context value</param>
public session(
    UCC_SESSION_TYPE sessionType, 
    IUccSessionManager sm,
    string pContextKey,
    string pContext)
{
    //new context object
    UccContext sessionContext = new UccContext();

    //if context value and key supplied by calling code
    // create named property in new context object
    if (pContext != null && pContextKey != null)
    {
        sessionContext.AddNamedProperty(
            pContextKey, 
            pContext);
    }

    string _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 with new session as event source,
    //session wrapper class (this) as event sink
    UCC_Advise<_IUccSessionEvents>(
            this._session, 
            this);
}

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

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

Show:
© 2014 Microsoft