Set Presence Information

The following code example demonstrates how to set the presence data and the local presence information.

Note  This example does not contain error checking or releases appropriate for real code.

C++ Code Example

// Set the presence information.

IRTCClientPresence2 pPresence2 = NULL;
BSTR bstrNameSpace = ::SysAllocString(L"http://schemas.example.com/samplenamespace");
BSTR bstrPresenceData = ::SysAllocString(L"Here I can publish information specific to this device.");
BSTR bstrNotes = ::SysAllocString(L"Here I can publish small notes specific to this device.");

// If ( bstrNameSpace == NULL ), process the error here.
// If ( bstrPresenceData == NULL ), process the error here.
// If ( bstrNotes == NULL ), process the error here.

// Query for the IRTCClientPresence2 interface.
hr = pClient->QueryInterface(IID_IRTCClientPresence2, 
                             (LPVOID *) &pPresence2);

// If (hr != S_OK), process the error here.

hr = pPresence2->SetPresenceData(bstrNameSpace, 
                                 bstrPresenceData);

// If (hr != S_OK), process the error here.

hr = pPresence2->SetLocalPresenceInfo(RTCXS_PRESENCE_ONLINE, 
                                      bstrNotes);

// If (hr != S_OK), process the error here.

Visual Basic Code Example

'
' Setting for your device
'

' Set the custom presence data for this device.
Call pPresence2.SetPresenceData ("http://examples.microsoft.com/sample-schema", "Here I can publish information specific to this device.")

' Set the presence state and notes for this device.
Call pPresence2.SetLocalPresenceInfo(RTCXS_PRESENCE_ONLINE, "Here I can publish small notes specific to this device.")

' Set the display name for this device.
pPresence2.PresenceProperty(RTCPP_DISPLAY_NAME) = "RTC Agent"

' Set the phone number for this device.
pPresence2.PresenceProperty(RTCPP_PHONENUMBER) = "555-0123"

' Set the e-mail for this device.
pPresence2.PresenceProperty(RTCPP_EMAIL) = "example@microsoft.com"

' Set the device name for this device.
pPresence2.PresenceProperty(RTCPP_DEVICE_NAME) = "Lab Tablet PC"