OnixS C++ FIX Engine  3.25.0
API Documentation
Listening to Session Events

OnixS C++ FIX Engine exposes the OnixS::FIX::ISessionListener class, whose virtual members are called by an instance of the OnixS::FIX::Session class, as response to a particular event occurred during the session life-time.

To be notified about a particular session event, overwrite appropriate member of the OnixS::FIX::ISessionListener class, and supply a descendant instance to the OnixS::FIX::Session's constructor.

The following table describes the meaning of all events, exposed by the OnixS::FIX::Session class in terms of of OnixS::FIX::ISessionListener class members.

Method (Event handler) Description
OnixS::FIX::ISessionListener::onInboundApplicationMsg Application-level message is received from the counterparty.
OnixS::FIX::ISessionListener::onInboundSessionMsg Session-level message is received from the counterparty.
OnixS::FIX::ISessionListener::onOutboundApplicationMsg Application-level message will be sent to the counterparty. This callback could be used to change fields that are set by the FIX Engine.
OnixS::FIX::ISessionListener::onOutboundSessionMsg Session-level message will be sent to the counterparty. This callback could be used to change the fields that are set by the FIX Engine.
OnixS::FIX::ISessionListener::onReceivedBytes Bytes are received from the wire.
OnixS::FIX::ISessionListener::onMessageSending Just before the FIX message is sent to the wire.
OnixS::FIX::ISessionListener::onResendRequest Sent application-level message is about to be resent to the counterparty.
OnixS::FIX::ISessionListener::onWarning Warning condition is detected.
OnixS::FIX::ISessionListener::onError Error condition is detected.
OnixS::FIX::ISessionListener::onStateChange Session state is changed.
Note
Session event handling/listening is synchronous operation. For this reason, it is recommended not to perform time-consuming tasks inside event handlers. For the same reason, it is not recommended to call from the event handler any Session method that could change Session state.

Example

class SessionStateListener : public ISessionListener
{
public:
virtual void Listener::onStateChange (SessionState::Enum newState, SessionState::Enum prevState, Session* session)
{
std::clog
<< "\nSession's state is changed"
<< ". Previous state was " << SessionState::toString(prevState)
<< ", new state is " << SessionState::toString(newState)
<< std::endl;
}
};