Session Forward
The following code example demonstrates how to forward an incoming session to another endpoint. 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 forwarding URI. BSTR bstrForwardURI = SysAllocString(L"Someone@microsoft.com"); // Call the Forward method under the IRTCSessionCallControl // interface with the forwarding URI. The call must be // in the incoming state (RTCSS_INCOMING) to call the // Forward method. hr = pIRTCSessionCallControl->Forward(bstrForwardURI); // If (hr != S_OK), process the error here. // When the call forward succeeds, the IRTCSessionStateChangeEvent // is fired with an RTCSS_DISCONNECTED session state. // The IRTCSessionStateChangeEvent is fired on the caller side with an // RTCSS_DISCONNECTED session state and a 302 status code (REDIRECT) // if the session was created with the RTCSS_FAIL_ON_REDIRECT // option. Otherwise, the call to Forward is handled directly by the // RTC Client API.
Visual Basic Code Example
' Set the error handling routine here. ' On Error GoTo MyErrorRoutine ' Declare the Forwarding URI; ' for example, "someone@microsoft.com". Dim strForwardURI As String ' Call the Forward method under the IRTCSessionCallControl ' interface with the forwarding URI. The call must be ' the incoming state to forward it. objSessionCallControl.Forward strForwardURI ' When the call forward succeeds, the IRTCSessionStateChangeEvent ' is fired with an RTCSS_DISCONNECTED session state. ' The IRTCSessionStateChangeEvent is fired on the caller side with an ' RTCSS_DISCONNECTED session state and a 302 status code (REDIRECT) ' if the session was created with the RTCSS_FAIL_ON_REDIRECT ' option. Otherwise, the call to ForwardURI is handled directly by the ' RTC Client API.