Session Transfer Accepted

The following code examples demonstrate how to accept a transfer attempt. The operations in the Initialize RTC, Create a Session and Make a Call, and Session Transfer code examples must be performed before using these examples.

Note  These examples do not contain error checking or releases appropriate for real code.

C++ Code Example 1

The following example shows how the Transferee accepts the transferred session.

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ON THE TRANSFEREE SIDE ...
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// The IRTCSessionReferredEvent is fired on the Transferee side.

// Declare the session referred event.
IRTCSessionReferredEvent *pEvent = NULL; 

BSTR  bstrReferToURI;
BSTR  bstrReferredByURI;
BSTR  bstrReferCookie;

long  lState;

// Get the IRTCSessionReferredEvent event. For information
// on how to receive events, see the "Handle Events" code
// example.

// The Transferee should call the Accept method when
// the event is fired to accept the transfer.
hr = pEvent->Accept();

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

// If the transfer is accepted, place the call with 
// the Transferor on hold.  (The Transferee can choose 
// to disconnect the session with the Transferor.)

//~~~~~~~~~~~~~~~~~~~~~~~~~~
// Create a new session here. 
// For information on how to create a session, see the
// "Create a Session and Make a Call" code example.
//~~~~~~~~~~~~~~~~~~~~~~~~~~

// The URI of the Transfer Target can be obtained as shown below. 
// This must be called before calling the AddParticipant method.
hr = pEvent->get_ReferToURI(&bstrReferToURI);

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

// Set these parameters before calling AddParticipant so 
// the Transfer Target knows that it is a transferred call.
hr = pEvent->put_ReferredByURI(&bstrReferredByURI);
hr = pEvent->put_ReferCookie(&bstrReferCookie);  

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~
// Add a participant to the session here. 
// For infomation on how to add a participant, see the
// "Create a Session and Make a Call" code example.
//~~~~~~~~~~~~~~~~~~~~~~~~~~

// The Transferee calls SetReferrredSessionState 
// under the session referred event to inform the 
// Transferor of the status of the call between 
// the Transferee and the Transfer Target.

// Change the parameter to RTCSS_DISCONNECTED if the
// call is not successful.
hr = pEvent->SetReferredSessionState(RTCSS_CONNECTED); 

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

C++ Code Example 2

The following example shows how the Transferee Target accepts the transferred session.

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ON THE TRANSFER TARGET SIDE ...
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// The Transfer Target should call the following 
// methods to verify whether the incoming call is a 
// referred call.

VARIANT_BOOL fIsReferred;
BSTR bstrReferredByURI;
BSTR bstrReferCookie;

IRTCSession                *pIRTCSession2  = NULL;
IRTCSessionCallControl     *pIRTCessionCallControl2  = NULL;
HRESULT                    hr = S_OK;

// Query for IRTCSessionCallControl using the 
// incoming IRTCSession interface.

// Call this method on the incoming session
// to see whether it is a referred call.
hr = pIRTCSessionCallControl2->get_IsReferred(&fIsReferred);  

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

// If this is a referred call, call the following 
// methods to get the URI of the Transferor.
hr = pIRTCSessionCallControl2->get_ReferredByURI(&bstrReferredByURI); 
hr = pIRTCSessionCallControl2->get_ReferCookie(&bstrReferCookie);

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

Visual Basic Code Example 1

The following example shows how the Transferee accepts the transferred session.

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

' Get the IRTCSessionReferredEvent event. For information
' on how to receive events, see the "Handle Events" code
' example.

' To accept the transfer, the Transferee should call the 
' Accept method when the event is fired.
objEvent.Accept

' If the transfer is accepted, place the call with the Transferor 
' on hold. The Transferee can choose to disconnect the 
' session with the Transferor. 

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Create a new session here (objSession2).
' For information on how to create a session, see the
' "Create a Session and Make a Call" code example.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Set the URI of the Transfer Target before calling 
' the AddParticipant method.  
strReferToURI = objEvent.ReferToURI

' Set the following information before calling
' AddParticipant so that the Transfer Target knows that 
' this is a transferred call.
' objSession2 is the newly created session.
objSession2.ReferredByURI = objEvent.ReferredByURI
objSession2.ReferCookie = objEvent.ReferCookie

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Call the AddParticipant method using the 
' created session objSession2 and strReferToURI.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' The Transferee calls SetReferredSessionState on
' the session referred event to send call status 
' (between Transferee and Transfer Target) to
' the Transferor. 
objEvent.SetReferredSessionState (RTCSS_CONNECTED)  
' Note: Change the parameter in the above call to 
' RTCSS_DISCONNECTD if the call is not successful. 

Visual Basic Code Example 2

The following example shows how the Transferee Target accepts the transferred session.

' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ON THE TRANSFER TARGET SIDE ...
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Set the error handling routine here. 
' On Error GoTo MyErrorRoutine 

' The Transfer Target should call the following methods
' to verify whether the incoming call is a referred call.

Dim fIsReferred as Boolean
Dim strReferredByURI as String, strReferCookie as String

Dim objSessionCallControl2 As IRTCSessionCallControl
Dim objSession3 As IRTCSession

' Query for the IRTCSessionCallControl interface using 
' the incoming session (IRTCSession).
Set objSessionCallControl2 = objSession3

' Call this method on the incoming session to 
' see whether it is a referred call.
fIsReferred = objSessionCallControl2.IsReferred


' If it is a referred call, call the following methods 
' to obtain the URI of the Transferor.
strReferredByURI = objSessionCallControl2.ReferredByURI
strReferCookie = objSessionCallControl2.ReferCookie