Share via


Handle Events

The following code examples demonstrate the implementation of an event handler. The operations in the Initialize RTC and Register to Receive Events code examples must be performed before using these examples.

Note  These examples do not contain error checking or releases appropriate for real code.

C++ Code Example

// Note: This method is in the CRTCOutgoing class, which
// implements the IRTCEventNotification interface.
HRESULT STDMETHODCALLTYPE
CRTCOutgoing::Event( RTC_EVENT RTCEvent,
                     IDispatch * pEvent )
{
if (NULL != pEvent) 
{
    // Process each event type.
    switch (RTCEvent)
    {
        case RTCE_CLIENT: 
            // Place process event code here.
            break;
        case RTCE_SESSION_STATE_CHANGE:
            // Place process event code here.
            break;
        case RTCE_MEDIA: 
            // Place process event code here.
            break;
        ....

        default:   
            // handle for default  
            break;
    }
}
return hr;
}

Visual Basic Code Example

Private Sub g_objRTCClientWithEvents_Event(ByVal RTCEvent As 
RTCCORELib.RTC_EVENT, ByVal pEvent As Object)

'Set the error handling routine here. 
' On Error GoTo MyErrorRoutine 

'Call the appropriate procedure to handle each type of event.
Select Case RTCEvent
      
    Case RTCE_SESSION_STATE_CHANGE
        Call SessionStateEvent(pEvent)
    ....       

    Case RTCE_MEDIA
        Call MediaEvent(pEvent)
            
End Select
End Sub