Event is the mechanism that BTT uses to communicate between
a client, server, host, and between the various components in the
toolkit.
Event notification consists of defined structures for sending a
toolkit-specific event (signaled by an event notifier) and for receiving
the event that processed by an event handler. The handler processes
the event or propagates it to other handlers.
Event manager
An event manager acts as the
event controller that controls notifiers and handlers to manage both
local and remote events. For remote event notifications between a
client workstation and a server workstation, an event manager instance
exists on the client workstation and another instance exists on the
server workstation. The local event manager listens to arriving event
and sends newly received event to objects which are interested in
receiving the event. If the object is located in a remote workstation,
the default behavior is to send the event to the remote workstation's
event manager so that it can then propagate the event to its local
handlers.
The event manager is implemented using the
EventManager class.
The
EventManager class provides two event notification
interfaces to perform two different functions:
- Firstly, register a workstation as a notifier, or a subscriber
for an event coming from a specific remote workstation. A workstation
can be a sender and receiver simultaneously and can be a client or
server.
- Secondly, register a handler for a specific local or remote event.
The following guide shows how and when you can use these
interfaces:
- During the application startup process, the client workstation
or a server workstation can be registered as a handler for specific
remote events signaled by specific notifiers. For remote events from
server workstation, register the client event manager as a handler
with the event manager on the server workstation. For local events
to remote server workstation, register the client event manager as
a handler so that it can pass the event to the event manager of the
server workstation listening for this event. By doing this registration
during the application startup process, the handling and notification
for these events keeps active during the whole life cycle of the application.
Note: Note that
at any time during the life of the application, the workstation can
be registered as a handler of a remote event (though this does not
happen frequently), or remove its handler identity.
- During a normal operation process, a client or server workstation
can register a handler to manage an event from a notifier. If the
notifier is local, the event manager adds the handler to the notifier's
list of handlers. If the notifier is remote (assumed if the event
manager can not find the notifier on the same workstation), the event
manager adds the handler to its own list of handlers. To send events
to the client, the server workstation registers itself as a handler
and uses the dispatch method to send the event to the client workstation.
Right after it sends the event, the server workstation can remove
itself from the notifier's list of handlers and finish its processing.