File Information
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: accept, attributes, protocol, removeEventFilter, setEventFilter, setEventFilterImpl, subscribe, transportForSubscriber, unsubscribe
Inherited Functions: duplicate, referenceCount, release
Nested Classes
struct SubscriberInfo
Types Aliases
FilterMap
using FilterMap = std::map < std::string, Poco::Any >;
NameValueMap
using NameValueMap = Transport::NameValueMap;
Ptr
using Ptr = Poco::AutoPtr < EventDispatcher >;
SubscriberMap
using SubscriberMap = std::map < std::string, SubscriberInfo::Ptr >;
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.
removeEventFilter
void removeEventFilter(
const std::string & subscriberURI,
const std::string & event
);
Removes the event filter for the given subscriber and event.
setEventFilter
template < typename T > void setEventFilter(
const std::string & subscriberURI,
const std::string & event,
typename EventFilter < T >::Ptr pFilter
);
Sets an event filter for the given subscriber and event.
If pFilter is null, removes the filter.
subscribe
void subscribe(
const std::string & subscriberURI,
const std::string & endpointURI,
Poco::Clock 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.
accept
template < typename T > bool accept(
const FilterMap & filters,
const std::string & event,
const T & value
);
setEventFilterImpl
void setEventFilterImpl(
const std::string & subscriberURI,
const std::string & event,
const Poco::Any & filter
);
Sets the event filter for the given subscriber and event.
If the given filter is empty, removes the filter.
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;