Share via


IUccSubscription.CreatePresentity 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 presentity identifying the publisher of category instances to be subscribed.

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

Syntax

'Declaration
Function CreatePresentity ( _
    pPresentityUri As UccUri, _
    pContext As UccContext _
) As UccPresentity
UccPresentity CreatePresentity (
    UccUri pPresentityUri,
    UccContext pContext
)
UccPresentity^ CreatePresentity (
    UccUri^ pPresentityUri, 
    UccContext^ pContext
)
UccPresentity CreatePresentity (
    UccUri pPresentityUri, 
    UccContext pContext
)
function CreatePresentity (
    pPresentityUri : UccUri, 
    pContext : UccContext
) : UccPresentity

Parameters

  • pPresentityUri
    A value of the IUccUri* (UccUri, for a .NET application) type. This specifies the SIP URI of the publisher.
  • pContext
    A value of the IUccContext* (UccContext, for a .NET application) type. This specifies optional application-specified properties related to this presentity.

Return Value

A value of the IUccPresentity** (IUccPresentity, for a .NET application) type. This returns the specified presentity.

Remarks

A remote user is represented by an IUccPresentity object that has properties for identifying the remote user location and context. By creating a presentity with an associated optional context, a local client adds a remote user to a subscription and provides context information about the remote user that can be useful when subscription events are handled by the client.Win32 COM/C++ Syntax

HRESULT CreatePresentity
(
   IUccUri* pPresentityUri,
   IUccContext* pContext,
   IUccPresentity** ppPresentity
);

Note

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.

Example

The example creates an instance of the UccContext coclass and a UccUri object representing the local user. With these two object, the example creates a presentity object. The new presentity object can be added to the subscription with a call to AddPresentity.

/// <summary>
/// Creates a new presentity instance to be added to subscription
/// </summary>
/// <param name="pSubscription">Subscription presentity factory object</param>
/// <param name="pPublisher">Publishing Uri</param>
/// <param name="pContextKey">meta data context key</param>
/// <param name="pContextValue">metadata context value</param>
/// <param name="pEventSink">Class instance implementing presentity event handlers</param>
/// <returns></returns>
private UccPresentity MakePresentity(
    UccSubscription pSubscription,
    UccUri pPublisher,
    string pContextKey,
    string pContextValue,
    _IUccPresentityEvents pEventSink)
{
    UccPresentity returnValue = null;
    if (pSubscription == null)
    {
        throw new ArgumentNullException(
            "pSubscription", 
            "Subscription cannot be null");
    }
    if (pPublisher == null)
    {
        throw new ArgumentNullException(
            "pPublisher", 
            "Publishing Uri cannot be null");
    }
    try
    {
        UccContext subContext = new UccContextClass();
        if (pContextKey.Length > 0 && pContextValue.Length > 0)
        {
            subContext.AddNamedProperty(pContextKey, pContextValue);
        }
        returnValue = pSubscription.CreatePresentity(
            pPublisher, 
            subContext);
        UCC_Advise<_IUccPresentityEvents>(returnValue, pEventSink);
    }
    catch (COMException)
    { }
    return returnValue;

}

Thread Safety

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

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

IUccSubscription Interface
IUccSubscription Members
Microsoft.Office.Interop.UccApi Namespace

Other Resources

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