Partager via


Recevoir un appel

L’exemple de code suivant illustre la gestion des nouvelles notifications d’appel, comme la recherche ou la création de terminaux appropriés pour restituer le média. Cet exemple est une partie de l’instruction switch qu’une application doit implémenter pour la gestion des événements. Le code lui-même peut être contenu dans l’implémentation de ITTAPIEventNotification::Event, ou la méthode Event peut publier un message sur un thread de travail qui contient le commutateur.

Avant d’utiliser cet exemple de code, vous devez effectuer les opérations dans Initialiser TAPI, Sélectionner une adresse et Inscrire des événements.

En outre, vous devez effectuer les opérations illustrées dans Sélectionner un terminal après la récupération des pointeurs d’interface ITBasicCallControl et ITAddress .

Notes

Cet exemple n’a pas la vérification des erreurs et les mises en production appropriées pour le code de production.

 

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

Événements

ITTAPIEventNotification

ITTAPI::RegisterCallNotifications

ITCallNotificationEvent

ITCallInfo

ITBasicCallControl

ITTerminalSupport