OnixS C++ FIX Engine  4.6.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 /// Error reason.
35 struct ErrorReason {
36  enum Enum {
37  /// General system-related error.
39 
40  /// 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 manual intervention be initiated.
46 
47  /// FIX Connection cannot be restored.
49 
50  /// Exception was thrown during processing of the incoming message.
52 
53  /// FIX message received is not valid.
55 
56  /// Exception was thrown in the client event handler implementation.
58  };
59 };
60 
61 /// Warning reason.
62 struct WarningReason {
63  enum Enum {
64  /// General system-related warning
66 
67  /// Garbled message is received.
69 
70  /// Telecommunication link error is detected.
72 
73  /// Sequence gap in the incoming messages is detected.
75 
76  /// ResendTimeout is elapsed.
77  ResendTimeout
78  };
79 };
80 
81 /// Session's Listener.
83 {
84 public:
85  /// @note FIX Engine/Session does NOT manage the lifetime of this listener.
87 
88  /// Is called when the message mode is `Message` and the application-level message is received from the counterparty.
89  ///
90  /// @note: do no call base method if you have overridden it in the derived class.
91  virtual void onInboundApplicationMsg(Message & message, Session * session) = 0;
92 
93  /// Is called when the message mode is `FlatMessage` and the application-level message is received from the counterparty.
94  ///
95  /// @note: do no call base method if you have overridden it in the derived class.
97  ;
98  }
99 
100  /// Is called when the message mode is `Message` and the session-level message is received from the counterparty.
101  /// @note: do no call base method if you have overridden it in the derived class.
102  virtual void onInboundSessionMsg(Message & /*message*/, Session * /*session*/) {
103  ;
104  }
105 
106  /// Is called when the message mode is `FlatMessage` and the session-level message is received from the counterparty.
107  /// @note: do no call base method if you have overridden it in the derived class.
108  virtual void onInboundSessionMsg(FlatMessage & /*message*/, Session * /*session*/) {
109  ;
110  }
111 
112  /// Is called when the application-level message is sent to the counterparty.
113  ///
114  /// @note: do no call base method if you have overridden it in the derived class.
115  /// @note: Message's sequence number is the preliminary one.
116  ///
117  /// @warning: It is called under session's lock.
118  virtual void onOutboundApplicationMsg(Message & /*message*/, Session * /*session*/) {
119  ;
120  }
121 
122  /// Is called when the session-level message is sent to the counterparty.
123  ///
124  /// @note: do no call base method if you have overridden it in the derived class.
125  /// @note: Message's sequence number is the preliminary one.
126  ///
127  /// @warning: It is called under session's lock.
128  virtual void onOutboundSessionMsg(Message & /*message*/, Session * /*session*/) {
129  ;
130  }
131 
132  /// Is called as soon as bytes are received from the wire.
133  virtual void onReceivedBytes(const char * /*bytes*/, size_t /*size*/, Session * /*session*/) {
134  ;
135  }
136 
137  /// Is called just before the FIX message is sent to the wire.
138  ///
139  /// @warning: It is called under session's lock.
140  virtual void onMessageSending(SequenceNumber /*msgSeqNum*/, char * /*bytes*/, size_t /*size*/,
141  Session * /*session*/) {
142  ;
143  }
144 
145  /// Is called when the session changes its state.
146  virtual void onStateChange(SessionState::Enum /*newState*/, SessionState::Enum /*prevState*/,
147  Session * /*session*/) {
148  ;
149  }
150 
151  /// Is called when the message mode is `Message` and the sent application-level message is about to be
152  /// re-sent to the counterparty in reply to the ResendRequest<2> message.
153  ///
154  /// @return `true` if the message should be re-sent, otherwise - `false`.
155  virtual bool onResendRequest(Message & /*message*/, Session * /*session*/) {
156  return false;
157  }
158 
159  /// Is called when the message mode is `FlatMessage` and the sent application-level message is about to be
160  /// re-sent to the counterparty in reply to the ResendRequest<2> message.
161  ///
162  /// @return `true` if the message should be re-sent, otherwise - `false`.
163  virtual bool onResendRequest(FlatMessage & /*message*/, Session * /*session*/) {
164  return false;
165  }
166 
167  /// Is called when an error condition is detected.
168  virtual void onError(ErrorReason::Enum /*reason*/, const std::string & /*description*/,
169  Session * /*session*/) {}
170 
171  /// Is called when a warning condition is detected.
172  virtual void onWarning(WarningReason::Enum /*reason*/, const std::string & /*description*/,
173  Session * /*session*/) {}
174 };
175 }
176 }
FIX Session - a bi-directional stream of ordered messages between two parties within a continuous seq...
Definition: Session.h:99
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.
virtual void onWarning(WarningReason::Enum, const std::string &, Session *)
Is called when a warning condition is detected.
virtual void onInboundApplicationMsg(FlatMessage &, Session *)
Is called when the message mode is FlatMessage and the application-level message is received from the...
Sequence gap in the incoming messages is detected.
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 access to FIX fields from a flat (tag=value) message.
Definition: FlatMessage.h:52
Exception was thrown during processing of the incoming message.
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)
General system-related error.
virtual void onOutboundApplicationMsg(Message &, Session *)
Is called when the application-level message is sent to the counterparty.
Exception was thrown in the client event handler implementation.
General system-related warning.
virtual void onOutboundSessionMsg(Message &, Session *)
Is called when the session-level message is sent to the counterparty.
FIX Connection cannot be restored.
unsigned int SequenceNumber
Alias for sequence mumber.
virtual void onInboundSessionMsg(FlatMessage &, Session *)
Is called when the message mode is FlatMessage and the session-level message is received from the cou...
Encapsulates operations over a FIX Message.
Definition: Message.h:49
FIX message received is not valid.
Telecommunication link error is detected.
virtual void onMessageSending(SequenceNumber, char *, size_t, Session *)
Is called just before the FIX message is sent to the wire.