Implement an Event Handler

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The final, but most important, part of event handling is implementing the event handler, which is application-specific. The following C++ code snippet provides an example with an implementation to handle an OnEnable event raised by an IUccEndpoint object after Enable is called on the endpoint instance.

STDMETHODIMP CSampleUccEndPoint::OnEnable( IUccEndpoint*, IUccOperationProgressEvent* pOperationprogressevent)
{
    VARIANT_BOOL vaComplete;
    HRESULT hr = pOperationprogressevent->get_IsComplete(&vaComplete);
    
    if (FAILED(hr))
        return hr;
    
    if(vaComplete == VARIANT_FALSE)
        return hr;
    
    HRESULT hrval;
    
    hr = pOperationprogressevent->get_StatusCode(&hrval);
    
    if (FAILED(hr))
        return hr;
    
    if (FAILED(hrval))
    {
        // Get the status text.
        BSTR val;
        hr = pOperationprogressevent->get_StatusText(&val);
        
        if (FAILED(hr))
            return hr;
        // Show status text, implementation omitted here.

    }   
    else
    {
        // Display that the endpoint is enabled.
        // Implementation is omitted here.
        
        this.m_bLoggedOn = true;
    }
      
    return S_OK;
}

Complete C++ samples using Unified Communications Client API are in the Samples folder under the installation directory of Unified Communications Client API. By default, the sample directory path is C:\Program Files\Microsoft UCCAPI\Samples.

See Also

Concepts

Catching Unified Communications Client API Events Using ATL Templates
Declare Event Source and Event Sink
Map Event Source with Event Sink
Connect Event Source and Event Sink