Empfangen eines Anrufs

Im folgenden Codebeispiel wird die Behandlung neuer Anrufbenachrichtigungen veranschaulicht, z. B. das Suchen oder Erstellen geeigneter Terminals zum Rendern der Medien. Dieses Beispiel ist ein Teil der Switch-Anweisung, die eine Anwendung für die Ereignisbehandlung implementieren muss. Der Code selbst kann in der Implementierung von ITTAPIEventNotification::Event enthalten sein, oder die Event-Methode kann eine Nachricht an einen Workerthread senden, der den Switch enthält.

Bevor Sie dieses Codebeispiel verwenden, müssen Sie die Vorgänge in Initialize TAPI, Select an Address und Register Events ausführen.

Außerdem müssen Sie die vorgänge ausführen, die unter Auswählen eines Terminals nach dem Abruf der Schnittstellenzeiger "ITBasicCallControl" und "ITAddress " veranschaulicht werden.

Hinweis

Dieses Beispiel verfügt nicht über die Fehlerüberprüfung und -releases, die für Produktionscode geeignet sind.

 

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

Ereignisse

ITTAPIEventNotification

ITTAPI::RegisterCallNotifications

ITCallNotificationEvent

ITCallInfo

ITBasicCallControl

ITTerminalSupport