OnixS C++ FIX Engine  4.2.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 
26 
27 namespace OnixS {
28 namespace FIX {
29 ONIXS_FIXENGINE_API_DECL(class, Message);
30 ONIXS_FIXENGINE_API_DECL(class, Session);
31 
32 /// Error reason.
33 struct ErrorReason {
34  enum Enum {
35  /// General system-related error.
37 
38  /// First message received is not a Logon message.
40 
41  /// The incoming message has a sequence number less than expected and the PossDupFlag is not set, it indicates a serious error.
42  /// It is strongly recommended that the session be terminated and manual intervention be initiated.
44 
45  /// FIX Connection cannot be restored.
47 
48  /// Exception was thrown during processing of the incoming message.
50 
51  /// FIX message received is not valid.
53 
54  /// Exception was thrown in the client event handler implementation.
56  };
57 };
58 
59 /// Warning reason.
60 struct WarningReason {
61  enum Enum {
62  /// General system-related warning
64 
65  /// Garbled message is received.
67 
68  /// Telecommunication link error is detected.
70 
71  /// Sequence gap in the incoming messages is detected.
72  SeqGapIsDetected
73  };
74 };
75 
76 /// Session's Listener.
78 {
79 public:
80  /// @note FIX Engine/Session does NOT manage the lifetime of this listener.
81  virtual ~ISessionListener() {}
82 
83  /// Is called when the application-level message is received from the counterparty.
84  ///
85  /// @note: do no call base method if you have overridden it in derived class.
86  virtual void onInboundApplicationMsg(Message & message, Session * session) = 0;
87 
88  /// Is called when the session-level message is received from the counterparty.
89  /// Note: do no call base method if you have overridden it in derived class.
90  virtual void onInboundSessionMsg(Message & /*message*/, Session * /*session*/) {
91  ;
92  }
93 
94  /// Is called when the application-level message is sent to the counterparty.
95  ///
96  /// @note: do no call base method if you have overridden it in the derived class.
97  /// @note: Message's sequence number is the preliminary one.
98  virtual void onOutboundApplicationMsg(Message & /*message*/, Session * /*session*/) {
99  ;
100  }
101 
102  /// Is called when the session-level message is is sent to the counterparty.
103  ///
104  /// @note: do no call base method if you have overridden it in the derived class.
105  /// @note: Message's sequence number is the preliminary one.
106  virtual void onOutboundSessionMsg(Message & /*message*/, Session * /*session*/) {
107  ;
108  }
109 
110  /// Is called as soon as bytes are received from the wire.
111  virtual void onReceivedBytes(const char * /*bytes*/, size_t /*size*/, Session * /*session*/) {
112  ;
113  }
114 
115  /// Is called just before the FIX message is sent to the wire.
116  virtual void onMessageSending(SequenceNumber /*msgSeqNum*/, char * /*bytes*/, size_t /*size*/,
117  Session * /*session*/) {
118  ;
119  }
120 
121  /// Is called when the session changes its state.
122  virtual void onStateChange(SessionState::Enum /*newState*/, SessionState::Enum /*prevState*/,
123  Session * /*session*/) {
124  ;
125  }
126 
127  /// Is called when the sent application-level message is about to be
128  /// re-sent to the counterparty in reply to the ResendRequest<2> message.
129  ///
130  /// @return 'true' if the message should be re-sent, otherwise - 'false'.
131  virtual bool onResendRequest(Message & /*message*/, Session * /*session*/) {
132  return false;
133  }
134 
135  /// Is called when an error condition is detected.
136  virtual void onError(ErrorReason::Enum /*reason*/, const std::string & /*description*/,
137  Session * /*session*/) {}
138 
139  /// Is called when a warning condition is detected.
140  virtual void onWarning(WarningReason::Enum /*reason*/, const std::string & /*description*/,
141  Session * /*session*/) {}
142 };
143 }
144 }
unsigned int SequenceNumber
Alias for sequence mumber.
virtual void onInboundSessionMsg(Message &, Session *)
Is called when the session-level message is received from the counterparty.
Session&#39;s Listener.
FIX Session - a bi-directional stream of ordered messages between two parties within a continuous seq...
Definition: Session.h:58
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
virtual void onError(ErrorReason::Enum, const std::string &, Session *)
Is called when an error condition is detected.
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.
First message received is not a Logon message.
General system-related warning.
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
General system-related error.
FIX message received is not valid.
Exception was thrown during processing of the incoming message.
Telecommunication link error is detected.
FIX Connection cannot be restored.
virtual void onReceivedBytes(const char *, size_t, Session *)
Is called as soon as bytes are received from the wire.
The incoming message has a sequence number less than expected and the PossDupFlag is not set...
virtual void onOutboundSessionMsg(Message &, Session *)
Is called when the session-level message is is sent to the counterparty.
Encapsulates operations over a FIX Message.
Definition: Message.h:49
virtual void onMessageSending(SequenceNumber, char *, size_t, Session *)
Is called just before the FIX message is sent to the wire.
virtual void onWarning(WarningReason::Enum, const std::string &, Session *)
Is called when a warning condition is detected.
virtual bool onResendRequest(Message &, Session *)
Is called when the sent application-level message is about to be re-sent to the counterparty in reply...
virtual void onStateChange(SessionState::Enum, SessionState::Enum, Session *)
Is called when the session changes its state.