Poco::RemotingNG

class EventDispatcher

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

Known Derived Classes: IoT::Devices::SensorEventDispatcher, IoT::Devices::SerialDeviceEventDispatcher, IoT::Devices::SwitchEventDispatcher, IoT::Modbus::ModbusMasterEventDispatcher, IoT::BtLE::PeripheralBrowserEventDispatcher, IoT::NetworkEnvironment::NetworkEnvironmentServiceEventDispatcher, IoT::BtLE::PeripheralEventDispatcher, IoT::CAN::CANEndpointEventDispatcher, IoT::MQTT::MQTTClientEventDispatcher, IoT::UDP::UDPEndpointEventDispatcher, IoT::XBee::XBeeNodeEventDispatcher, IoT::DeviceStatus::DeviceStatusServiceEventDispatcher, IoT::MobileConnection::MobileConnectionServiceEventDispatcher, IoT::WebEvent::WebEventNotifierEventDispatcher, IoT::Devices::StringDatapointEventDispatcher, IoT::Devices::AccelerometerEventDispatcher, IoT::Devices::BooleanSensorEventDispatcher, IoT::Devices::CameraEventDispatcher, IoT::Devices::CompositeEventDispatcher, IoT::Devices::CounterDatapointEventDispatcher, IoT::Devices::CounterEventDispatcher, IoT::Devices::DeviceEventDispatcher, IoT::Devices::EnumDatapointEventDispatcher, IoT::Devices::FlagsDatapointEventDispatcher, IoT::Devices::LEDEventDispatcher, IoT::Devices::MagnetometerEventDispatcher, IoT::Devices::RotaryEncoderEventDispatcher, IoT::Devices::ScalarDatapointEventDispatcher, IoT::Devices::GyroscopeEventDispatcher, IoT::Devices::IOEventDispatcher, IoT::Devices::TriggerEventDispatcher, IoT::Devices::BarcodeReaderEventDispatcher, IoT::Devices::BooleanDatapointEventDispatcher, IoT::Devices::DatapointEventDispatcher, IoT::Devices::GNSSSensorEventDispatcher, IoT::Devices::VectorDatapointEventDispatcher

Member Summary

Member Functions: accept, attributes, protocol, removeEventFilter, setEventFilter, setEventFilterImpl, subscribe, transportForSubscriber, unsubscribe

Inherited Functions: duplicate, referenceCount, release

Nested Classes

struct SubscriberInfo protected

 

Types Aliases

FilterMap protected

using FilterMap = std::map < std::string, Poco::Any >;

NameValueMap

using NameValueMap = Transport::NameValueMap;

Ptr

using Ptr = Poco::AutoPtr < EventDispatcher >;

SubscriberMap protected

using SubscriberMap = std::map < std::string, SubscriberInfo::Ptr >;

Constructors

EventDispatcher

EventDispatcher(
    const std::string & protocol
);

Creates an EventDispatcher.

Destructor

~EventDispatcher virtual

virtual ~EventDispatcher();

Destroys the EventDispatcher.

Member Functions

attributes inline

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 inline

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 inline

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 protected inline

template < typename T > bool accept(
    const FilterMap & filters,
    const std::string & event,
    const T & value
);

setEventFilterImpl protected

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 protected

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 protected

Poco::FastMutex _mutex;

_subscribers protected

SubscriberMap _subscribers;

Securely control IoT edge devices from anywhere   Connect a Device