OnixS C++ B3 BOE Binary Order Entry  1.2.0
API Documentation
SessionListener.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 <OnixS/B3/BOE/ABI.h>
23 #include <OnixS/B3/BOE/Messaging.h>
25 
26 #include <string>
27 
28 namespace OnixS {
29 namespace B3 {
30 namespace BOE {
31 
32 ONIXS_B3_BOE_API_DECL(class, Session);
33 
34 /**
35  * Session Warning Reason.
36  */
38 {
39  enum Enum
40  {
41  /// General session-related warning.
43 
44  /// Incoming message sequence gap is detected.
46 
47  /// Unexpected SBE Schema version is received from B3.
49 
50  /// Received an unexpected `NextSeqNo` value.
52 
53  /// Received an unsupported message type.
55 
56  /// The incoming message has a sequence number is out of the expected range and the <i>PossRetransFlag</i> is
57  /// set, it indicates a warning. It is strongly recommended that the session be terminated and manual intervention
58  /// be initiated.
60 
61  /// Received a message with an unexpected sessionId
63 
64  /// Raised when the `KeepAliveInterval` has expired and no keep alive message is received.
66 
67  /// Exception was thrown from user's event handler.
69 
70  /// An exception is thrown from the user-provided Session Storage
72 
73  /// Session state cannot be restored.
75 
76  /// Raised when the AsyncFileBasedStorage queue exceeded `SessionSettings::asyncFileBasedStorageQueueMaxSize`
78 
79  /// Raised when the license will expire in less than `SessionSettings::licenseAlertingDaysBeforeExpiration`
81 
82  /// The <i>Retransmit Reject</i> message is received in reply to the <i>Retransmit Request</i> message.
84 
85  /// Telecommunication link error is detected.
87 
88  /// After sending the initial Negotiate or Establish message the telecommunication link error is detected.
90 
91  /// Error setting socket option
93 
94  /// Cannot backup the file.
96 
97  /// Session state cannot be restored.
99  };
100 
101  ONIXS_B3_BOE_EXPORTED static const char* toString(Enum type) ONIXS_B3_BOE_NOTHROW;
102 };
103 
104 /**
105  * Session Error Reason.
106  */
108 {
109  enum Enum
110  {
111  /// Internal error
113 
114  /// A general session-related error.
116 
117  /// First message received is not the <i>NegotiationResponse</i> or <i>EstablishmentAck</i> message.
119 
120  /// The <i>Negotiation Reject</i> message is received in reply to the <i>Negotiation</i> message.
122 
123  /// The <i>Establishment Reject</i> message is received in reply to the <i>Establish</i> message.
125 
126  /// The <i>Terminate</i> message is received in reply to the <i>Establish</i> message.
128 
129  /// The incoming message has a sequence number less than expected and the <i>PossRetransFlag</i> is not
130  /// set, it indicates a serious error.
131  /// The incoming message has a sequence number less than expected and the <i>PossRetransFlag</i> is not set, it
132  /// indicates a serious error. It is strongly recommended that the session be terminated and manual intervention
133  /// be initiated.
135 
136  /// Connection cannot be restored.
138 
139  /// Connection cannot be established.
141 
142  /// Exception during processing of an incoming message.
144 
145  /// Received an invalid incoming message.
147 
148  /// When two times the `KeepAliveInterval` has expired and no keep alive
149  /// message is received then the session is terminated ungracefully and will need to be re-established.
151 
152  /// Telecommunication link error is detected.
154 
155  /// After sending the initial Negotiate or Establish message the telecommunication link error is detected.
157 
158  /// The Exchange sent the initial Terminate message.
160 
161  /// The maximum size of the incoming message gap queue is exceeded.
163 
164  /// An exception is thrown from the user-provided Session Storage
166 
167  /// A message with unexpected sessionVerId is received.
169 
170  /// Session state cannot be restored.
172  };
173 
174  ONIXS_B3_BOE_EXPORTED static const char* toString(Enum type) ONIXS_B3_BOE_NOTHROW;
175 };
176 
177 /// Represents a timestamp of the received data.
178 /// If the source is `None`, no timestamp is available.
180 {
181  enum Source
182  {
183  /// No timestamp available.
185 
186  /// Timestamp provided by the OS kernel / user-level network stack.
188 
189  /// Timestamp provided by the network card.
190  Hardware
191  };
192 
193  /// The timestamp.
196 
197  /// \return a human-readable presentation.
198  ONIXS_B3_BOE_EXPORTED std::string toString() const;
199 };
200 
201 
202 /// Session's Listener.
204 {
205 public:
206  virtual void onNotApplied(const Messaging::NotApplied8 & /*msg*/, Session* /*sn*/) {}
207 
208  /// Invoked when NegotiateResponse2 message has received.
210 
211  /// Invoked when NegotiateReject3 message has received.
212  virtual void onNegotiateReject(const Messaging::NegotiateReject3&, Session* /*sn*/){}
213 
214  /// Invoked when EstablishAck5 message has received.
215  virtual void onEstablishAck(const Messaging::EstablishAck5&, Session* /*sn*/){}
216 
217  /// Invoked when EstablishReject6 message has received.
218  virtual void onEstablishReject(const Messaging::EstablishReject6&, Session* /*sn*/){}
219 
220  /// Invoked when Terminate7 message has received.
221  virtual void onTerminate(const Messaging::Terminate7&, Session* /*sn*/){}
222 
223  /// Invoked when Sequence9 message has received.
224  virtual void onSequence(const Messaging::Sequence9&, Session* /*sn*/){}
225 
226  /// Invoked when Retransmission13 message has received.
227  virtual void onRetransmission(const Messaging::Retransmission13&, Session* /*sn*/){}
228 
229  /// Invoked when RetransmitReject14 message has received.
231 
232  /// Invoked when ExecutionReportNew200 message has received.
234 
235  /// Invoked when ExecutionReportModify201 message has received.
237 
238  /// Invoked when ExecutionReportCancel202 message has received.
240 
241  /// Invoked when ExecutionReportTrade203 message has received.
243 
244  /// Invoked when ExecutionReportReject204 message has received.
246 
247  /// Invoked when ExecutionReportForward205 message has received.
249 
250  /// Invoked when BusinessMessageReject206 message has received.
252 
253  /// Invoked when SecurityDefinitionResponse301 message has received.
255 
256  /// Invoked when QuoteRequest401 message has received.
257  virtual void onQuoteRequest(const Messaging::QuoteRequest401&, Session* /*sn*/){}
258 
259  /// Invoked when QuoteStatusReport402 message has received.
261 
262  /// Invoked when Quote403 message has received.
263  virtual void onQuote(const Messaging::Quote403&, Session* /*sn*/){}
264 
265  /// Invoked when QuoteCancel404 message has received.
266  virtual void onQuoteCancel(const Messaging::QuoteCancel404&, Session* /*sn*/){}
267 
268  /// Invoked when QuoteRequestReject405 message has received.
270 
271  /// Invoked when PositionMaintenanceReport503 message has received.
273 
274  /// Invoked when AllocationReport602 message has received.
276 
277  /// Invoked when OrderMassActionReport702 message has received.
279 
280  /// Called as soon as bytes are received from the wire.
281  virtual void onReceivedBytes(const char * /*bytes*/, size_t /*size*/, const ReceivedDataTimestamp& /*timestamp*/, Session * /*sn*/) {}
282 
283  /// Called when the SBE message is about to be sent to the wire.
284  virtual void onMessageSending(char * /*bytes*/, size_t /*size*/, Session * /*sn*/) {}
285 
286  /// Called when the session changes its state.
287  virtual void onStateChange(SessionStateId::Enum /*newState*/, SessionStateId::Enum /*prevState*/, Session * /*sn*/) {}
288 
289  /// Called when an error condition is detected.
290  /// \note the message argument provided is a message which caused the problem, must be checked to be valid before usage
291  virtual void onError(SessionErrorReason::Enum /*reason*/, const std::string & /*description*/, Session * /*sn*/, Messaging::SbeMessage) {}
292 
293  /// Called when a warning condition is detected.
294  /// \note the message argument provided is a message which caused the problem, must be checked to be valid before usage
295  virtual void onWarning(SessionWarningReason::Enum /*reason*/, const std::string & /*description*/, Session * /*sn*/, Messaging::SbeMessage) {}
296 
297 protected:
298  virtual ~SessionListener() = 0;
299 };
300 
301 }
302 }
303 }
After sending the initial Negotiate or Establish message the telecommunication link error is detected...
The time point without the time-zone information.
Definition: Time.h:467
NegotiateReject message is sent when B3 rejects a Negotiate message sent by the client.
Definition: Messages.h:932
#define ONIXS_B3_BOE_API_DECL(typeKind, typeName)
Definition: ABI.h:29
Unexpected SBE Schema version is received from B3.
OrderMassActionReport message is used to acknowledge an OrderMassActionRequest message.
Definition: Messages.h:25890
virtual void onRetransmitReject(const Messaging::RetransmitReject14 &, Session *)
Invoked when RetransmitReject14 message has received.
virtual void onExecutionReportForward(const Messaging::ExecutionReportForward205 &, Session *)
Invoked when ExecutionReportForward205 message has received.
virtual void onAllocationReport(const Messaging::AllocationReport602 &, Session *)
Invoked when AllocationReport602 message has received.
virtual void onEstablishReject(const Messaging::EstablishReject6 &, Session *)
Invoked when EstablishReject6 message has received.
Received an unexpected NextSeqNo value.
Execution Report - Reject message notifies the reason a client request was not accepted by Matching E...
Definition: Messages.h:14052
Terminate message is sent to indicate that the sender is going to disconnect the TCP socket connectio...
Definition: Messages.h:2509
RetransmitReject message is sent when a RetransmitRequest message is rejected by B3. More details are described in the Message Specification Guidelines document.
Definition: Messages.h:3941
virtual void onNegotiateResponse(const Messaging::NegotiateResponse2 &, Session *)
Invoked when NegotiateResponse2 message has received.
virtual void onExecutionReportReject(const Messaging::ExecutionReportReject204 &, Session *)
Invoked when ExecutionReportReject204 message has received.
virtual void onExecutionReportNew(const Messaging::ExecutionReportNew200 &, Session *)
Invoked when ExecutionReportNew200 message has received.
virtual void onTerminate(const Messaging::Terminate7 &, Session *)
Invoked when Terminate7 message has received.
ExecutionReport - Cancel message is sent in response to Order Cancel Request as well as to report uns...
Definition: Messages.h:11657
Execution Report - New message is sent in response to a NewOrderSingle or SimpleNewOrder messages...
Definition: Messages.h:9246
#define ONIXS_B3_BOE_NOTHROW
Definition: Compiler.h:182
Execution Report - Modify message is sent in response to OrderCancelReplaceRequest or SimpleModifyOrd...
Definition: Messages.h:10465
Raised when the license will expire in less than SessionSettings::licenseAlertingDaysBeforeExpiration...
Session&#39;s Listener.
An exception is thrown from the user-provided Session Storage.
Incoming message sequence gap is detected.
The incoming message has a sequence number is out of the expected range and the PossRetransFlag is se...
Quote message is used as the response to a QuoteRequest message, tradeable, and restricted tradeable ...
Definition: Messages.h:19625
#define ONIXS_B3_BOE_EXPORTED
Definition: Compiler.h:181
virtual void onQuoteStatusReport(const Messaging::QuoteStatusReport402 &, Session *)
Invoked when QuoteStatusReport402 message has received.
virtual void onNotApplied(const Messaging::NotApplied8 &, Session *)
Raised when the AsyncFileBasedStorage queue exceeded SessionSettings::asyncFileBasedStorageQueueMaxSi...
The QuoteRequestReject message is used when a QuoteRequest is not accept by B3 due to missing or inco...
Definition: Messages.h:20922
Represents a timestamp of the received data.
The Terminate message is received in reply to the Establish message.
Raised when the KeepAliveInterval has expired and no keep alive message is received.
Telecommunication link error is detected.
BusinessMessageReject message can reject an application-level message which fulfills session level ru...
Definition: Messages.h:16229
virtual void onQuoteCancel(const Messaging::QuoteCancel404 &, Session *)
Invoked when QuoteCancel404 message has received.
virtual void onSecurityDefinitionResponse(const Messaging::SecurityDefinitionResponse301 &, Session *)
Invoked when SecurityDefinitionResponse301 message has received.
Definition: Defines.h:40
Telecommunication link error is detected.
virtual void onQuote(const Messaging::Quote403 &, Session *)
Invoked when Quote403 message has received.
virtual void onWarning(SessionWarningReason::Enum, const std::string &, Session *, Messaging::SbeMessage)
Called when a warning condition is detected.
EstablishmentReject message is sent when an Establish message is rejected by B3 informing the reason ...
Definition: Messages.h:2148
virtual void onRetransmission(const Messaging::Retransmission13 &, Session *)
Invoked when Retransmission13 message has received.
The QuoteStatusReport message is to inform the current status of forward acceptance.
Definition: Messages.h:18655
virtual void onExecutionReportTrade(const Messaging::ExecutionReportTrade203 &, Session *)
Invoked when ExecutionReportTrade203 message has received.
The Retransmit Reject message is received in reply to the Retransmit Request message.
The SecurityDefinitioresponse message is sent in response to an attempt to create a new security defi...
Definition: Messages.h:17232
The QuoteCancel message is used to cancel a previous QuoteRequest message.
Definition: Messages.h:20356
Execution Report – Trade/Trade Bust message is sent with order fills that were traded and processed ...
Definition: Messages.h:12819
virtual void onNegotiateReject(const Messaging::NegotiateReject3 &, Session *)
Invoked when NegotiateReject3 message has received.
Messaging::Timestamp time_
The timestamp.
Received a message with an unexpected sessionId.
The Negotiation Reject message is received in reply to the Negotiation message.
An exception is thrown from the user-provided Session Storage.
The NegotiationResponse message is sent when a Negotiate message from the client is accepted by B3...
Definition: Messages.h:590
After sending the initial Negotiate or Establish message the telecommunication link error is detected...
virtual void onExecutionReportCancel(const Messaging::ExecutionReportCancel202 &, Session *)
Invoked when ExecutionReportCancel202 message has received.
The Establishment Reject message is received in reply to the Establish message.
virtual void onPositionMaintenanceReport(const Messaging::PositionMaintenanceReport503 &, Session *)
Invoked when PositionMaintenanceReport503 message has received.
virtual void onQuoteRequest(const Messaging::QuoteRequest401 &, Session *)
Invoked when QuoteRequest401 message has received.
virtual void onError(SessionErrorReason::Enum, const std::string &, Session *, Messaging::SbeMessage)
Called when an error condition is detected.
virtual void onReceivedBytes(const char *, size_t, const ReceivedDataTimestamp &, Session *)
Called as soon as bytes are received from the wire.
virtual void onSequence(const Messaging::Sequence9 &, Session *)
Invoked when Sequence9 message has received.
First message received is not the NegotiationResponse or EstablishmentAck message.
A message with unexpected sessionVerId is received.
Received an invalid incoming message.
A FIXP Session.
Definition: Session.h:47
virtual void onExecutionReportModify(const Messaging::ExecutionReportModify201 &, Session *)
Invoked when ExecutionReportModify201 message has received.
Retransmission message is sent when a RetransmitRequest message from the client is accepted by B3...
Definition: Messages.h:3633
The incoming message has a sequence number less than expected and the PossRetransFlag is not set...
AllocationReport message is as response of AllocationInstruction message.
Definition: Messages.h:24748
Timestamp provided by the OS kernel / user-level network stack.
The maximum size of the incoming message gap queue is exceeded.
Exception was thrown from user&#39;s event handler.
Sequence message specifies the sequence number of the next business message both: Recoverable (B3 to ...
Definition: Messages.h:3073
Execution Report – Forward message is sent with order fills were traded and processed on Matching En...
Definition: Messages.h:15178
The Exchange sent the initial Terminate message.
PositionMaintenanceReport message is sent owner of a position (holder) in response to a PositionMaint...
Definition: Messages.h:23001
virtual void onQuoteRequestReject(const Messaging::QuoteRequestReject405 &, Session *)
Invoked when QuoteRequestReject405 message has received.
virtual void onOrderMassActionReport(const Messaging::OrderMassActionReport702 &, Session *)
Invoked when OrderMassActionReport702 message has received.
virtual void onBusinessMessageReject(const Messaging::BusinessMessageReject206 &, Session *)
Invoked when BusinessMessageReject206 message has received.
virtual void onEstablishAck(const Messaging::EstablishAck5 &, Session *)
Invoked when EstablishAck5 message has received.
virtual void onStateChange(SessionStateId::Enum, SessionStateId::Enum, Session *)
Called when the session changes its state.
NotApplied message is sent when B3 detects messages that already been sent (concept of idempotence) o...
Definition: Messages.h:2807
static const char * toString(Enum type) noexcept
When two times the KeepAliveInterval has expired and no keep alive message is received then the sessi...
The Quote Request message is used within the context of this Forward transaction in which two parties...
Definition: Messages.h:17703
virtual void onMessageSending(char *, size_t, Session *)
Called when the SBE message is about to be sent to the wire.
The EstablishmentAck message is sent when an Establish message is accepted by B3. EstablishmentAck me...
Definition: Messages.h:1782