This documentation is archived and is not being maintained.

Presence Scenarios: Custom Containers

Applications are not limited to the containers that Office Communicator uses. For example, applications can create custom containers that contain members of a team for a specific project or a set of users with a particular expertise.

In the Microsoft Unified Communications Client SDK, you create a custom container by creating a container category instance, adding members, and then publishing it, as follows:

Creating a Custom Container Using the Microsoft Unified Communications Client SDK
  1. Choose a container ID that is not listed in the table in Table of Office Communicator Containers and Categories.

  2. Create a category instance with category name containers.

  3. Set the category instance’s container ID to 0 (zero). New containers are published in container 0.

  4. Set the category instance ID to the custom container ID you chose in step 1.

  5. Set the expiration type to static.

  6. Add members using each user’s SIP URI.

  7. Publish the container category instance.

The following code sample illustrates how to create a custom container using the Microsoft Unified Communications Client SDK. The variable pubMgr is an IUccPublicationManager, and the variable customContainerId is an integer that is the ID for the custom container that is being created.

IUccCategoryInstance containerInst = pubMgr.CreatePublishableCategoryInstance(
    "containers",
    0,
    customContainerId,
    UCC_CATEGORY_INSTANCE_EXPIRE_TYPE.UCCCIET_STATIC,
    0);
containerInst.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD;

// Add member
IUccContainer containerCustom = containerInst as IUccContainer;
IUccContainerMember member =
    pubMgr.CreateContainerMember("sip:someone@example.com", UCC_CONTAINER_MEMBERSHIP_SCOPE.UCCCMS_USER);
containerCustom.AddMember(member);

// Publish container
IUccPublication pub = pubMgr.CreatePublication() as IUccPublication;
if (pub != null)
{
    UccAppUtilities.AdviseForEvents<_IUccPublicationEvent>(pub, this);

    pub.AddPublishableCategoryInstance(containerInst);
    pub.Publish(null);
}

// Publish category instance to container customContainerId
// ...

You can now publish category instances to the container ID that you chose. If you are publishing category instances that Office Communicator uses, Office Communicator displays that information as long as it does not have other published instances of the same category and ID that have been published in a container with a higher container ID than your custom container. For example, if you published a state of container 350, Office Communicator users who are in the Personal container (ID = 400) or the Block container (ID = 32000) see the state published there, but users who are not see the state that you published, because all other Office Communicator users have IDs lower than 300.

Note that it is also possible to force Office Communications Server to create a container for you if you specify a container ID that does not correspond to any of your existing containers when you publish a new or updated category instance. The container that Office Communications Server creates contains only the category instance for which you specified the new container ID. It does not contain members. The client is responsible for adding container members to this new container after receiving a container list from Office Communications Server as part of in-band provisioning.

Consider a business where employees work on processing documents using a custom application. At any given time, an employee should only be working on one document. As questions about the documents come up, the employees call a manager to get assistance. The custom application knows which document each employee is working on. When they call or message the manager, a different custom application on the manager’s computer automatically brings up the document for the manager to look at, thus saving the manager time in locating the appropriate document.

In this scenario, the employees’ custom application could create a new container with an instance ID of 501 and adds manager as a member. When a new document is opened, the application creates a note category instance with an instance ID that is not being used by Office Communicator, such as 0x60000000. An ID for the document is converted into a string and set to be the activity property or attribute for the category instance. The category instance is published in container 501 with an expiration type of static so that it remains in the container until a more recent version of the same state is published.

The manager’s custom application reacts to events when the category instance is added or modified. It stores the ID in a table along with the employee’s SIP URI. When the application detects an incoming phone call or instant message from that SIP URI, it retrieves the document using the ID and displays it.

An example of the XML data for the note is as follows. The category ID of 0x6000000 is expressed as 100663296, and the document ID is Doc579370945 in the block tag of the note.

<publication categoryName="note" instance="100663296" 
    container="501" version="0" expireType="static">
    <note xmlns="http://schemas.microsoft.com/2006/09/sip/note">
        <body type="personal" uri="" startTime="2009-02-20T21:56:36Z" 
            endTime="2009-02-20T21:56:36Z">Doc579370945</body>
    </note>
</publication>

Note that in this scenario, none of the published information is displayed by Office Communicator.

Show: