The handler uses a concept of events and event listeners to notify the client code about various aspects of market data processing and deliver data to the user (e.g., receiving a security definition or a direct book update).
The SDK groups events and provides classes with virtual members (event listeners) for each group. Client code may override any or all listener members to implement the processing of a particular event.
Associating an event listener with an instance of the OnixS::CME::MDH::Handler class is called subscribing to events.
The table below describes events groups and shows the correspondence between the events, listeners and handler settings methods that are used to subscribe to events:
Listener | Method | Description |
---|---|---|
OnixS::CME::MDH::HandlerListener | OnixS::CME::MDH::HandlerListeners::handler For example: handler.settings().listeners().handler(&listener); | The handler invokes the event listener members during market data processing. Events reflect processing session stages like entering or leaving the recovery cycle, recovery completion status (OnixS::CME::MDH::RecoveryCompletionArgs), and resuming real-time data processing. |
OnixS::CME::MDH::MarketDataListener | OnixS::CME::MDH::HandlerListeners::marketData For example: handler.settings().listeners().marketData(&listener); | The handler invokes the event listener members when it begins or ends processing various market data entities (e.g., a packet or a message). Events are triggered only for market data accepted by the handler and according to CME's rules. The handler does not invoke members of the listener for any duplicated or out-of-order packets. |
OnixS::CME::MDH::SecurityListener | OnixS::CME::MDH::HandlerListeners::security For example: handler.settings().listeners().security(&listener); | Members of the given listener are invoked to reflect security-related events like the receiving of trade, security status, and order book updates. By default, members of this listener are invoked for each security available on the channel. However, it is possible to restrict callback invocation for a set of securities using the OnixS::CME::MDH::Handler::selectInstruments member. See Selecting securities of interest for more information. |
OnixS::CME::MDH::ChannelFeedListener | OnixS::CME::MDH::HandlerListeners::feeds For example: handler.settings().listeners().feeds(&listener); | The OnixS::CME::MDH::ChannelFeedListener members are invoked each time a feed-related event occurs. |
The sample below demonstrates listening to Handler's events: