Library: RemotingNG
Package: ORB
Header: Poco/RemotingNG/EventDispatcher.h
The EventDispatcher is responsible for delivering events fired by service objects to remote subscribers.
Event dispatching and delivery in RemotingNG works as follows: If a service object has events, the corresponding RemoteObject class will have a delegate member function for every service object event, as well as providing all the events itself (inherited from the interface class). During construction of the RemoteObject, its delegates will be bound to the service objects' events. The delegates will then simply fire the RemoteObject's event, when invoked.
The EventDispatcher subclass for a specific service will have delegate functions for all service object events, which will be bound to the RemoteObject's events. The EventDispatcher class maintains a list of event subscribers. When an event is fired, the EventDispatcher's delegate will dispatch the event to all registered event subscribers, using a Transport. This works in a very similar way to a Proxy.
Direct Base Classes: Poco::RefCountedObject
All Base Classes: Poco::RefCountedObject
Member Functions: attributes, protocol, subscribe, transportForSubscriber, unsubscribe
Inherited Functions: duplicate, referenceCount, release
typedef Transport::NameValueMap NameValueMap;
typedef Poco::AutoPtr < EventDispatcher > Ptr;
typedef std::map < std::string, SubscriberInfo::Ptr > SubscriberMap;
EventDispatcher(
const std::string & protocol
);
Creates an EventDispatcher.
virtual ~EventDispatcher();
Destroys the EventDispatcher.
AttributedObject & attributes(
const std::string & subscriberURI
);
Returns the attributes for the subscriber identified by the given URI. The attributes are stored in the Transport object.
const std::string & protocol() const;
Returns the protocol to be used for delivering event messages to subscribers.
void subscribe(
const std::string & subscriberURI,
const std::string & endpointURI,
Poco::Timestamp expireTime = 0
);
Registers a remote EventSubscriber identified by the given subscriberURI. Events will be sent to the specified endpoint, which must be a proper RemotingNG URI. Depending on the actual transport-specific events implementation, subscriberURI and enpoint may be the same or different.
If a non-null expireTime is given, the subscription will automatically expire at the time given in expireTime.
If a subscription with the given subscriberURI already exists, the expireTime of the existing subscription will be updated.
void unsubscribe(
const std::string & subscriberURI
);
Unregisters the remote EventSubscriber identified by the given URI.
Throws a Poco::NotFoundException if no subscription exists.
Transport & transportForSubscriber(
const std::string & subscriberURI
);
Returns the Transport object for communicating with the remote EventSubscriber identified by the given URI.
Throws a Poco::NotFoundException if the subscriber is not known.
Poco::FastMutex _mutex;
SubscriberMap _subscribers;