OnixS C++ FIX Engine  4.12.0
API Documentation
ISessionListener.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
22 #include <string>
23 
27 
28 namespace OnixS {
29 namespace FIX {
30 ONIXS_FIXENGINE_API_DECL(class, Message);
31 ONIXS_FIXENGINE_API_DECL(class, FlatMessage);
32 ONIXS_FIXENGINE_API_DECL(class, Session);
33 
34 /// The error reason.
35 struct ErrorReason {
36  enum Enum {
37  /// The general system-related error.
39 
40  /// The first message received is not a Logon message.
42 
43  /// The incoming message has a sequence number less than expected and the PossDupFlag is not set, it indicates a serious error.
44  /// It is strongly recommended that the session be terminated and a manual intervention be initiated.
46 
47  /// The FIX Connection cannot be restored.
49 
50  /// An exception was thrown during processing of the incoming message.
52 
53  /// The FIX message received is not valid.
55 
56  /// An exception was thrown in the client event handler implementation.
58 
59  /// Socket options cannot be set.
61  };
62 };
63 
64 /// The warning reason.
65 struct WarningReason {
66  enum Enum {
67  /// The general system-related warning
69 
70  /// A garbled message is received.
72 
73  /// The telecommunication link error is detected.
75 
76  /// The sequence gap in the incoming messages is detected.
78 
79  /// The ResendTimeout is elapsed.
81 
82  /// Cannot re-establish the FIX Connection after the reconnect attempt.
83  CannotConnect
84  };
85 };
86 
87 /// The session's Listener.
89 {
90 public:
91  /// @note the FIX Engine/Session does NOT manage the lifetime of this listener.
93 
94  /// Is called when the message mode is `Message` and the application-level message is received from the counterparty.
95  ///
96  /// @note: do no call the base method if you have overridden it in the derived class.
97  virtual void onInboundApplicationMsg(Message & message, Session * session) = 0;
98 
99  /// Is called when the message mode is `FlatMessage` and the application-level message is received from the counterparty.
100  ///
101  /// @note: do no call the base method if you have overridden it in the derived class.
103 
104  /// Is called when the message mode is `Message` and the session-level message is received from the counterparty.
105  /// @note: do no call the base method if you have overridden it in the derived class.
106  virtual void onInboundSessionMsg(Message & /*message*/, Session * /*session*/) {}
107 
108  /// Is called when the message mode is `FlatMessage` and the session-level message is received from the counterparty.
109  /// @note: do no call the base method if you have overridden it in the derived class.
110  virtual void onInboundSessionMsg(FlatMessage & /*message*/, Session * /*session*/) {}
111 
112  /// Is called when the application-level message is sent to the counterparty.
113  ///
114  /// @note: do no call the base method if you have overridden it in the derived class.
115  /// @note: The message's sequence number is the preliminary one.
116  ///
117  /// @warning: It is called under the session's lock.
118  virtual void onOutboundApplicationMsg(Message & /*message*/, Session * /*session*/) {}
119 
120  /// Is called when the session-level message is sent to the counterparty.
121  ///
122  /// @note: do no call the base method if you have overridden it in the derived class.
123  /// @note: The message's sequence number is the preliminary one.
124  ///
125  /// @warning: It is called under the session's lock.
126  virtual void onOutboundSessionMsg(Message & /*message*/, Session * /*session*/) {}
127 
128  /// Is called as soon as bytes are received from the wire.
129  virtual void onReceivedBytes(const char * /*bytes*/, size_t /*size*/, Session * /*session*/) {}
130 
131  /// Is called just before the FIX message is sent to the wire.
132  ///
133  /// @warning: It is called under the session's lock.
134  virtual void onMessageSending(SequenceNumber /*msgSeqNum*/, char * /*bytes*/, size_t /*size*/, Session * /*session*/) {}
135 
136  /// Is called when the session changes its state.
137  virtual void onStateChange(SessionState::Enum /*newState*/, SessionState::Enum /*prevState*/, Session * /*session*/) {}
138 
139  /// Is called when the message mode is `Message` and the sent application-level message is about to be
140  /// re-sent to the counterparty in reply to the ResendRequest<2> message.
141  ///
142  /// @return `true` if the message should be re-sent, otherwise - `false`.
143  virtual bool onResendRequest(Message & /*message*/, Session * /*session*/) { return false; }
144 
145  /// Is called when the message mode is `FlatMessage` and the sent application-level message is about to be
146  /// re-sent to the counterparty in reply to the ResendRequest<2> message.
147  ///
148  /// @return `true` if the message should be re-sent, otherwise - `false`.
149  virtual bool onResendRequest(FlatMessage & /*message*/, Session * /*session*/) { return false; }
150 
151  /// Is called when the ResendRequest<2> message is received and the session is about to start to resend messages.
152  virtual void onResendingStarted(SequenceNumber /*beginSeqNo*/, SequenceNumber /*endSeqNo*/, Session* /*session*/) {}
153 
154  /// Is called when the resending process is completed.
155  virtual void onResendingFinished(SequenceNumber /*beginSeqNo*/, SequenceNumber /*endSeqNo*/, Session* /*session*/) {}
156 
157  /// Is called when an error condition is detected.
158  virtual void onError(ErrorReason::Enum /*reason*/, const std::string & /*description*/, Session * /*session*/) {}
159 
160  /// Is called when a warning condition is detected.
161  virtual void onWarning(WarningReason::Enum /*reason*/, const std::string & /*description*/, Session * /*session*/) {}
162 };
163 }
164 }
The FIX Session - a bi-directional stream of ordered messages between two parties within a continuous...
Definition: Session.h:97
virtual void onStateChange(SessionState::Enum, SessionState::Enum, Session *)
Is called when the session changes its state.
virtual void onReceivedBytes(const char *, size_t, Session *)
Is called as soon as bytes are received from the wire.
The warning reason.
virtual void onWarning(WarningReason::Enum, const std::string &, Session *)
Is called when a warning condition is detected.
virtual void onResendingStarted(SequenceNumber, SequenceNumber, Session *)
Is called when the ResendRequest<2> message is received and the session is about to start to resend m...
virtual void onInboundApplicationMsg(FlatMessage &, Session *)
Is called when the message mode is FlatMessage and the application-level message is received from the...
The sequence gap in the incoming messages is detected.
The session&#39;s Listener.
#define ONIXS_FIXENGINE_DEFAULT
Definition: Compiler.h:176
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
The incoming message has a sequence number less than expected and the PossDupFlag is not set...
Provides an access to FIX fields from a flat (tag=value) message.
Definition: FlatMessage.h:109
An exception was thrown during processing of the incoming message.
The first message received is not a Logon message.
virtual void onInboundSessionMsg(Message &, Session *)
Is called when the message mode is Message and the session-level message is received from the counter...
virtual void onError(ErrorReason::Enum, const std::string &, Session *)
Is called when an error condition is detected.
virtual bool onResendRequest(FlatMessage &, Session *)
Is called when the message mode is FlatMessage and the sent application-level message is about to be ...
virtual bool onResendRequest(Message &, Session *)
Is called when the message mode is Message and the sent application-level message is about to be re-s...
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
The error reason.
The general system-related error.
virtual void onOutboundApplicationMsg(Message &, Session *)
Is called when the application-level message is sent to the counterparty.
An exception was thrown in the client event handler implementation.
The general system-related warning.
virtual void onOutboundSessionMsg(Message &, Session *)
Is called when the session-level message is sent to the counterparty.
The FIX Connection cannot be restored.
unsigned int SequenceNumber
Alias for the sequence number.
virtual void onInboundSessionMsg(FlatMessage &, Session *)
Is called when the message mode is FlatMessage and the session-level message is received from the cou...
The ResendTimeout is elapsed.
Encapsulates operations over a FIX Message.
Definition: Message.h:49
The FIX message received is not valid.
The telecommunication link error is detected.
virtual void onResendingFinished(SequenceNumber, SequenceNumber, Session *)
Is called when the resending process is completed.
virtual void onMessageSending(SequenceNumber, char *, size_t, Session *)
Is called just before the FIX message is sent to the wire.