Partager via


Answer a Call

The following code example shows how to receive an incoming call. The operations in the Initialize the Communications Service and Register to Receive Events examples must be performed before using this code.

**Note   **This code has not been thoroughly tested, does not contain error checking, and is not intended for production use.

IRTCSessionStateChangeEvent *pISessionState = NULL;
RTC_SESSION_STATE SessionState;
// Create the session state interface.
hr = pIDispatch->QueryInterface( IID_IRTCSessionStateChangeEvent,
                          reinterpret_cast<void**> (&pISessionState));
// if (hr != S_OK) process error here.
// Get the current session state.
hr = pISessionState->get_State(&SessionState);
// if (hr != S_OK) process error here.
// Handle all session states.
switch(SessionState)
{
    ...
    // Handle the incoming call.
    case RTCSS_INCOMING:
    {
        // Play a ring on the local computer.
        m_pIRTCClient->PlayRing(RTCRT_PHONE, VARIANT_TRUE)
         hr = pISessionState->get_Session(&pIRTCSession);
         // if (hr != S_OK) process error here.
         // Answer the incoming session.
         hr = pIRTCSession->Answer();
         // if (hr != S_OK) process error here. 
         break;
    }
}

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.