Once the Handler is started, it listens to a market data from the network, processes it (decodes messages, validates message order, updates order books) and invokes client code for further processing.
The Handler processes market data asynchronously and uses concept of events and event listeners to notify client code about a particular occasion like receiption of security definition or direct book update.
For each event like Error Occurred Handler provides an interface (C++ class with pure virtual members) like OnixS::Euronext::XDP::ErrorListener. Client code must implement this interface (C++ class) to be able to handle events of a particular type. Handler also exposes a member like OnixS::Euronext::XDP::Handler::registerErrorListener which allows to associate an instance of the event handler with a appropriate event in bounds of a particular instance of the OnixS::Euronext::XDP::Handler class.
Associating event listener with an instance of the OnixS::Euronext::XDP::Handler class is also called subscribing to an event.
There're multiple events exposed by the Handler.
Below table describes events exposed by the Handler as well as depicts correspondence between events, interfaces for listeners and the Handler's members to subscribe to an event:
Listener (C++ class) to be implemented | Handler's member to register listener | Description |
OnixS::Euronext::XDP::ErrorListener | OnixS::Euronext::XDP::Handler::registerErrorListener | Notifies about abnormal situations during the processing of the market data. |
OnixS::Euronext::XDP::ExchangeListener | OnixS::Euronext::XDP::Handler::registerExchangeListener | Notifies about received text messages from Exchange officials. |
OnixS::Euronext::XDP::InfoListener | OnixS::Euronext::XDP::Handler::registerInfoListener | Notifies about some important actions of handler. |
OnixS::Euronext::XDP::MarketListener | OnixS::Euronext::XDP::Handler::registerMarketListener | Notifies about market data processing. |
OnixS::Euronext::XDP::StandingDataListener | OnixS::Euronext::XDP::Handler::registerStandingDataListener | Notifies about securities updates. |
Following sample demonstrates how to listen to notifications about security definition receiption:
class MyListener : StandingDataListener { public: MyListener(){} private: virtual void onOutrightSecurity(Handler * handler, const Security & security) { cout << "Outright Security Definition received for security '" << security << "'." << endl; } virtual void onStrategySecurity(Handler * handler, const Security & security) { cout << "Strategy Security Definition received for security '" << security << "'." << endl; } }; ... Settings settings; // Settings initialization goes here. ... Handler handler(serviceId, settings); MyListener listener; handler.registerStandingDataListener(&listener); handler.start(); ...