Session Hold and Unhold

The following code example demonstrates how to place an existing session on and off hold. The operations in the Initialize RTC and Create a Session and Make a Call code examples must be performed before using this example.

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

C++ Code Example

// Declare the Session Call Control interface.
IRTCSession               *pIRTCSession   =  NULL;
IRTCSessionCallControl    *pIRTCSessionCallControl  = NULL;
HRESULT  hr = S_OK;

// Declare the Hold/Unhold cookie.
// The cookies used for Hold and Unhold are 
// independent of each other.
long    lCookie = 0;  

// Query for the IRTCSessionCallControl interface.
hr = pIRTCSession->QueryInterface (IID_IRTCSessionCallControl,
                                   (LPVOID **) &pIRTCSessuibCallControl);

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

// Call the hold method under the IRTCSessionCallControl 
// interface with a long value as the cookie. 
// The call must be in the connected state 
// to place the call on hold.
hr = pIRTCSessionCallControl->Hold(lCookie);

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

// When the Call hold succeeds, the IRTCSessionStateChangeEvent
// is fired, indicating that the call has entered the hold state. 
// This event will indicate that the session state (RTC_SESSION_STATE)
// is in RTCSS_HOLD.

// Call the Unhold method in the IRTCSessionCallControl 
// interface with a long value as the cookie.
// The call has to be in the hold state to unhold the call.
hr = pIRTCSessionCallControl->Unhold(lCookie);

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

// When the Call Unhold succeeds, IRTCSessionStateChangeEvent 
// is fired, indicating that the call is in the connected state.
// This event will indicate that the session state (RTC_SESSION_STATE)
// is in RTCSS_CONNECTED.

Visual Basic Code Example

' Set the error handling routine here. 
' On Error GoTo MyErrorRoutine 

' Declare the Session Call Control interface
' and session interface.
Dim objSessionCallControl As IRTCSessionCallControl
Dim objSession As IRTCSession

' Declare the Hold/Unhold cookie.
' The cookies used for Hold and Unhold are
' independent of each other.
Dim lCookie As Long                

// Query for the IRTCSessionCallControl interface.
Set objSessionCallControl = objSession

' Call the Hold method under the IRTCSessionCallControl
' interface with a long value as the cookie. The call must
' be in the connected state to place a call on hold.
objSessionCallControl.Hold lCookie

' Call the Unhold method under the IRTCSessionCallControl 
' interface with a long value as the cookie. The call has 
' to be in the hold state to unhold it.  
objSessionCallControl.UnHold lCookie

' When the call to Unhold succeeds, the IRTCSessionStateChangeEvent
' is fired with an RTCSS_CONNECTED session state, 
' indicating that the call is in the connected state.