Catching Unified Communications Client API Events Using ATL Templates
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.
In COM, event handling involves an implementation of the IDispatch interface to invoke a registered event handler when a certain event is raised in the source object. A special case of the IDispatch interface is dispinterface, which is used to define the events in Unified Communications Client API. Event handling, thus, involves implementing the event handlers, registering the implemented event handlers with the objects raising the events, and invoking the registered event handlers when the corresponding events occur. Objects raising events are also known as event sources. In Unified Communications Client API, event sources are represented by IUnknown interface instances.
The MFC library exposes ATL template classes that implement these basic and common functionalities of event handling, including registration and invocation of an event handler. An example is the IDispEventSimpleImpl class. Here, event registration amounts to advising an event source of an event handler implementation. An MFC application can take advantage of these template classes and focuses on the application-specific aspect of the event handling, namely, implementing the event handling logic.
This section describes how an MFC application can use the ATL templates to register event handlers and have them properly invoked when the corresponding events occur. The ATL template class of IDispEventSimpleImpl is used as an example to aid the discussions.
- Declare Event Source and Event Sink
Describes how to declare an event source and two event sinks using an ATL template class.
- Map Event Source with Event Sink
Describes how to map an event source with event sinks using ATL macros.
- Connect Event Source and Event Sink
Describes how to establish a connection between an event source and the event sinks.
- Implement an Event Handler
Provides an example illustrating how an event handler can be implemented.