Share via


Ricevere una chiamata

Nell'esempio di codice seguente viene illustrata la gestione delle nuove notifiche di chiamata, ad esempio la ricerca o la creazione di terminali appropriati per il rendering dei supporti. Questo esempio è una parte dell'istruzione switch che un'applicazione deve implementare per la gestione degli eventi. Il codice stesso può essere contenuto nell'implementazione di ITTAPIEventNotification::Event o il metodo Event può inviare un messaggio a un thread di lavoro che contiene l'opzione.

Prima di usare questo esempio di codice, è necessario eseguire le operazioni in Inizializzare TAPI, Selezionare un indirizzo e Registrare eventi.

È inoltre necessario eseguire le operazioni illustrate in Selezionare un terminale seguendo il recupero dei puntatori dell'interfaccia ITBasicCallControl e ITAddress .

Nota

Questo esempio non include il controllo degli errori e le versioni appropriate per il codice di produzione.

 

// 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. 
}

Eventi

ITTAPIEventNotification

ITTAPI::RegisterCallNotifications

ITCallNotificationEvent

ITCallInfo

ITBasicCallControl

ITTerminalSupport