Library: RemotingNG
Package: ORB
Header: Poco/RemotingNG/EventDispatcher.h
Description
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.
Inheritance
Direct Base Classes: Poco::RefCountedObject
All Base Classes: Poco::RefCountedObject
Member Summary
Member Functions: attributes, protocol, subscribe, transportForSubscriber, unsubscribe
Inherited Functions: duplicate, referenceCount, release
Nested Classes
struct SubscriberInfo
Types
NameValueMap
typedef Transport::NameValueMap NameValueMap;
Ptr
typedef Poco::AutoPtr < EventDispatcher > Ptr;
SubscriberMap
typedef std::map < std::string, SubscriberInfo::Ptr > SubscriberMap;
Constructors
EventDispatcher
EventDispatcher(
const std::string & protocol
);
Creates an EventDispatcher.
Destructor
~EventDispatcher
virtual ~EventDispatcher();
Destroys the EventDispatcher.
Member Functions
attributes
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.
protocol
const std::string & protocol() const;
Returns the protocol to be used for delivering event messages to subscribers.
subscribe
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 endpointURI 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.
unsubscribe
void unsubscribe(
const std::string & subscriberURI
);
Unregisters the remote EventSubscriber identified by the given URI.
Throws a Poco::NotFoundException if no subscription exists.
transportForSubscriber
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.
Variables
_mutex
Poco::FastMutex _mutex;
_subscribers
SubscriberMap _subscribers;