Initiating a Session
The document is archived and information here might be outdated

Initiating a Session

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.

After a user is signed in, a user session must be created. To do so, the client must send an initiateSession request. The server then creates a session object and returns the associated session ID to the calling client in the synchronous response (cwaResponses), if the request is processed successfully. The client must cache the session ID and references it in any other requests until the session is closed. These other requests include method calls and event polls. This is also a good place to start event polling provided that an initiateSession request has succeeded.

The successful initiateSession request generates an event response from the Communicator Web Access Server. This event response contains the following information:

  • Existing contact groups

  • Self-Presence information including the logged on users Contact Card

  • Subscribed contacts, their current presence status, and their Contact Card.

  • Custom configurations such as default search behavior

  • Container contents

The Unified Communications API client application uses this information to display the users contact list.

The following C# code snippet shows how to make an InitiateSession request.

public void InitiateSession()

    // If a session does not exist, then create an outbound
    // request object, send InitiateSession request
    // and finally create the inbound channel thread.
    if (sessionId == 0)
        // Default parameters are used when the session is
        // initialized, particiularly, when system-defined categories
        // are subscribed.
        string strRequest = "<cwaRequests xmlns=\"\">" +
                            "   <initiateSession>" +
                            "   </initiateSession>" +
        bool succeeded = SendRequest(
        if (!succeeded)

        ackId = 0;                // to get all events from the start

        // Create a background thread for data channel.
        dataChannel = new BackgroundWorker();
        dataChannel.DoWork += new DoWorkEventHandler(DataChannel);
        dataChannel.WorkerSupportsCancellation = true;

        // Wait for the event response from the InitiateRequest and
        // then start the background thread and making any other
        // requests

An implementation of the DataChannel is shown in Setting Up Data Channels.

The BackgroundWorker class is supported in the Microsoft .NET Framework 2.0.

© 2016 Microsoft