接聽通話

下列程式碼範例示範如何處理新的通話通知,例如尋找或建立適當的終端機來轉譯媒體。 此範例是應用程式必須實作以處理事件之 switch 語句的一部分。 程式碼本身可能包含在 ITTAPIEventNotification::Event的實作中,或 Event 方法可能會將訊息張貼至包含 參數的背景工作執行緒。

使用此程式碼範例之前,您必須在 初始化 TAPI選取位址註冊事件中執行作業。

此外,您必須在擷取ITBasicCallControlITAddress介面指標之後,執行選取終端機中所述的作業。

注意

此範例沒有適用于生產程式碼的錯誤檢查和版本。

 

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

事件

ITTAPIEventNotification

ITTAPI::RegisterCallNotifications

ITCallNotificationEvent

ITCallInfo

ITBasicCallControl

ITTerminalSupport