Page tree
Skip to end of metadata
Go to start of metadata

The events API provides components with a way to signal other components that a certain event has occurred. For instance a WWW proxy might issue an event when the user makes a request or a response is received. A virus scanner might signal an event when some malware has been detected. Other components can register themselves as event sinks and be notified when those events have occurred. 

Setting up an event source

Event generators are called event sources and their general object structure is as follows:

EventOverview

Adding event source support to your component requires:

  1. Registering a class (template) for your event source with EventRegisterSourceClass. This class describes the events and parameters to those events that instantiations of the event source will contain. You can then instantiate an event source based on this template without having to respecify all of the events and parameters again. For example: The WWW Proxy Service in WinGate registers a source class that describes the events a WWW proxy service can create. Because you can have multiple proxy services, each with the exact same events and event parameter types, all that is needed is to register the event source class once, and then instantiate a new event source from this class when the user creates a new WWW Proxy Service.
  2. Add events to the class with EventRegisterEvent
  3. Add datum (parameters) to the events of the class with EventRegisterEventDatum
  4. Optionally place the event into a realm with EventAssociateRealm
  5. Instantiate the source with EventRegisterEventSource

 

Signalling an event

Before signalling an event you need to set up an event source and its associated events with calls to EventRegisterSourceClassEventRegisterEventSource and EventRegisterEvent amongst others. Once your source and events are set up, you can signal an event by calling EventProcessEvent passing in an EventContextHandle that describes the event you wish to send.

The fields in the EventContextHandle that you need to set are as follows:

After setting up the event context, you can call EventProcessEvent

 

Processing an event

In order to process events you need to register an event sink. This can be a full sink or a minisink.

A full sink requires you to register the sink and then manage it via the events API. You can attach it to event, detach, receive notifications of new events in the system and much more. The WinGate Policy Engine component is one such sink component. It dynamically attaches and detaches event sinks when users drop event sources into the various policies.

A minisink on the other hand is registered by the component and then the events system manages displaying and hooking the minisink to compatible events. You just need to supply a few functions via the EventMiniSinkEngineInterface and EventMiniSinkGUIInterface and the framework does the rest. There are of course limitations to minisinks and they are described more in the Minisinks section.

Once the sink is registered then when the event is triggered the framework will call your handler function (EventSinkEvent or EventMiniSinkEvaluate depending on the type of sink)

 

Event processing is a serialised operation. When an event occurs, the event handlers for that event are processed one after the other with each handler able to cancel event handling when they process the event.

  • No labels