Recibir una llamada

En el ejemplo de código siguiente se muestra el control de las nuevas notificaciones de llamada, como buscar o crear terminales adecuados para representar los medios. Este ejemplo es una parte de la instrucción switch que una aplicación debe implementar para el control de eventos. El propio código puede estar incluido en la implementación de ITTAPIEventNotification::Event, o el método Event puede publicar un mensaje en un subproceso de trabajo que contiene el modificador.

Antes de usar este ejemplo de código, debe realizar las operaciones en Inicializar TAPI, Seleccionar una dirección y Registrar eventos.

Además, debe realizar las operaciones que se muestran en Seleccionar un terminal después de la recuperación de los punteros de interfaz ITBasicCallControl y ITAddress .

Nota

Este ejemplo no tiene la comprobación de errores y las versiones adecuadas para el código de producción.

 

// pEvent is an IDispatch pointer for the ITCallNotificationEvent interface of the
// call object created by TAPI, and is passed into the event handler by TAPI. 

case TE_CALLNOTIFICATION:
{
    // Get the ITCallNotification interface.
    ITCallNotificationEvent * pNotify;
    hr = pEvent->QueryInterface( 
            IID_ITCallNotificationEvent, 
            (void **)&pNotify 
            );
    // If ( hr != S_OK ) process the error here. 
    
    // Get the ITCallInfo interface.
    ITCallInfo * pCallInfo;
    hr = pNotify->get_Call( &pCallInfo);
    // If ( hr != S_OK ) process the error here. 

    // Get the ITBasicCallControl interface.
    ITBasicCallControl * pBasicCall;
    hr = pCallInfo->QueryInterface(
            IID_ITBasicCallControl,
            (void**)&pBasicCall
            );
    // If ( hr != S_OK ) process the error here. 

    // Get the ITAddress interface.
    ITAddress * pAddress;
    hr = pCallInfo->get_Address( &pAddress );
    // If ( hr != S_OK ) process the error here. 

    // Create the required terminals for this call.
    {
        // See the Select a Terminal code example.
    }
    // Complete incoming call processing.
    hr = pBasicCall->Answer();
    // If ( hr != S_OK ) process the error here. 
}

Eventos

ITTAPIEventNotification

ITTAPI::RegisterCallNotifications

ITCallNotificationEvent

ITCallInfo

ITBasicCallControl

ITTerminalSupport