Menerima Panggilan

Contoh kode berikut menunjukkan penanganan pemberitahuan panggilan baru, seperti menemukan atau membuat terminal yang sesuai untuk merender media. Contoh ini adalah bagian dari pernyataan pengalihan yang harus diterapkan aplikasi untuk penanganan peristiwa. Kode itu sendiri mungkin terkandung dalam implementasi ITTAPIEventNotification::Event, atau metode Peristiwa dapat memposting pesan ke utas pekerja yang berisi sakelar.

Sebelum menggunakan contoh kode ini, Anda harus melakukan operasi di Inisialisasi TAPI, Pilih Alamat, dan Daftarkan Peristiwa.

Selain itu, Anda harus melakukan operasi yang diilustrasikan di Pilih Terminal setelah pengambilan pointer antarmuka ITBasicCallControl dan ITAddress .

Catatan

Contoh ini tidak memiliki pemeriksaan kesalahan dan rilis yang sesuai untuk kode produksi.

 

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

Peristiwa

ITTAPIEventNotification

ITTAPI::RegisterCallNotifications

ITCallNotificationEvent

ITCallInfo

ITBasicCallControl

ITTerminalSupport