OnixS C++ FIX Engine 4.13.0
API Documentation
Loading...
Searching...
No Matches
Session.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#include <set>
24#include <vector>
25#include <utility>
26#include <iosfwd>
27#include <limits>
28
32
33
35
44
46
48
51
52
53namespace OnixS {
54namespace FIX {
60
63 enum Enum {
66
69 };
70};
71
72namespace Core {
73namespace Messaging {
74class Message;
75}
76}
77
78template<typename MsgType>
80{
82 typedef std::vector<FlatMessage*> MsgBatchType;
83 typedef std::vector<OnixS::FIX::Core::Messaging::Extras::FlatMessage*> CoreMsgBatchType;
84};
85
86template<>
88{
90 typedef std::vector<Message*> MsgBatchType;
91 typedef std::vector<OnixS::FIX::Core::Messaging::Message*> CoreMsgBatchType;
92};
93
98{
99public:
111 const std::string & senderCompId,
112 const std::string & targetCompId,
113 const Dictionary & dictionary,
114 ISessionListener * listener,
117
130 ISessionReactor * reactor,
131 const std::string & senderCompId,
132 const std::string & targetCompId,
133 const Dictionary & dictionary,
134 ISessionListener * listener,
137
150 const std::string & senderCompId,
151 const std::string & targetCompId,
152 const Dictionary & dictionary,
153 bool keepSequenceNumbersAfterLogout,
157
158
172 ISessionReactor * reactor,
173 const std::string & senderCompId,
174 const std::string & targetCompId,
175 const Dictionary & dictionary,
176 bool keepSequenceNumbersAfterLogout,
180
194 const std::string & senderCompId,
195 const std::string & targetCompId,
196 const Dictionary & dictionary,
197 bool keepSequenceNumbersAfterLogout,
199 const std::string & customSessionKey,
202
217 ISessionReactor * reactor,
218 const std::string & senderCompId,
219 const std::string & targetCompId,
220 const Dictionary & dictionary,
221 bool keepSequenceNumbersAfterLogout,
223 const std::string & customSessionKey,
226
231
239 Session & clearOutboundQueue(bool removeFragmentedPacket = false);
240
247
254
261
267 int listenPort() const;
268
275
281 std::string localNetworkInterface() const;
282
289
295 unsigned short localPort() const;
299 typedef std::pair<unsigned short, unsigned short> LocalPortRange;
300
307
314
319 bool tcpNoDelayOption() const;
320
324 Session & tcpNoDelayOption(bool improveLatency = true);
325
332
338
344
349
355
360
366
371
377
382
388
393
399
404
410
415
421
426
431 bool validateChecksum() const;
432
437
442 unsigned messageGrouping() const;
443
447 Session & messageGrouping(unsigned numberOfMessagesToGroup);
448
453
458
462 bool useSpinLock() const;
463
467 Session & useSpinLock(bool value);
468
474
485
490
495 int reconnectAttempts() const;
496
501
506 int reconnectInterval() const;
507
514
520
528
534
539
545
551 std::string sslCertificateFile() const;
552
560 Session & sslCertificateFile(const std::string & file);
561
567 std::string sslPrivateKeyFile() const;
568
576 Session & sslPrivateKeyFile(const std::string & file);
577
584
591
597 Session & sslVerifyPeer(bool verify);
598
605 bool sslVerifyPeer() const;
606
614 Session & sslClientSni(const std::string & hostName);
615
619 const std::string & sslClientSni() const;
620
626 Session & sslCaFile(const std::string & value);
627
633 std::string sslCaFile() const;
634
641
648
655
662
673
684 Session & logonAsInitiator(const std::string & host, int port, bool setResetSeqNumFlag);
685
696 Session & logonAsInitiator(const std::string & host, int port);
697
705 Session & logonAsInitiator(const std::string & host, int port, int heartbeatIntervalSec);
706
714 Session & logonAsInitiator(const std::string & host, int port, int heartbeatIntervalSec, bool setResetSeqNumFlag);
715
723 Session & logonAsInitiator(const std::string & host, int port, int heartbeatIntervalSec, Message * customLogonMsg);
724
732 Session & logonAsInitiator(const std::string & host, int port, int heartbeatIntervalSec, Message * customLogonMsg, bool setResetSeqNumFlag);
733
741 Threading::SharedFuture<void> logonAsInitiatorAsync(const std::string & host, int port, int heartbeatIntervalSec, Message * customLogonMsg, bool setResetSeqNumFlag);
742
754
768 Session & logout(const std::string & text);
769
783
796 Session & logout(Message * customLogoutMessage);
797 Session & logout(FlatMessage * customLogoutMessage);
798
812
819
833
846
850 template<typename MsgType> class MsgBatch;
851
853 {
854 typedef MsgBatchTraits<Message> MBT;
855 typedef MsgBatchTraits<FlatMessage> SBT;
856
857 static void init(MBT::CoreMsgBatchType & coreBatch);
858 static void init(SBT::CoreMsgBatchType & coreBatch);
859 static void add(MBT::MsgBatchType & batch, MBT::CoreMsgBatchType & coreBatch, MBT::MessagePtr & msg);
860 static void add(SBT::MsgBatchType & batch, SBT::CoreMsgBatchType & coreBatch, SBT::MessagePtr & msg);
861 static void clear(MBT::MsgBatchType & batch);
862 static void clear(SBT::MsgBatchType & batch);
863
864 template<typename MsgType> friend class MsgBatch;
865 };
866
867 template<typename MsgType>
868 class MsgBatch
869 {
870 typedef MsgBatchTraits<MsgType> Traits;
871
872 friend class Session;
873
874 typename Traits::MsgBatchType batch_;
875 typename Traits::CoreMsgBatchType coreBatch_;
876
877 MsgBatch(const MsgBatch&);
878 MsgBatch & operator=(const MsgBatch&);
879
880 public:
881
883 typedef typename Traits::MsgBatchType::iterator iterator;
884 typedef typename Traits::MsgBatchType::const_iterator const_iterator;
885
886 MsgBatch() { MsgBatchHelper::init(coreBatch_); }
887 ~MsgBatch() { MsgBatchHelper::clear(batch_); }
888
889 void add(MessagePtr & msg) { MsgBatchHelper::add(batch_, coreBatch_, msg); }
890
891 MsgType & operator[](size_t index) { return *batch_[index]; }
892 const MsgType & operator[](size_t index) const { return *batch_[index]; }
893
894 size_t size() const { return batch_.size(); }
895
896 const_iterator begin() const { return batch_.begin(); }
897 iterator begin() { return batch_.begin(); }
898
899 const_iterator end() const { return batch_.end(); }
900 iterator end() { return batch_.end(); }
901 };
902
906
925 Session & send(MessageBatch & msgs, size_t maxPacketSize = (std::numeric_limits<size_t>::max)());
926 Session & send(FlatMessageBatch & msgs, size_t maxPacketSize = (std::numeric_limits<size_t>::max)());
927
939 Session & send(FlatMessageBatch & msgs, SessionSendMode::Enum mode, size_t maxPacketSize = (std::numeric_limits<size_t>::max)());
940
957
980 Session & sendAsIs(FlatMessageBatch & msgs, size_t maxPacketSize = (std::numeric_limits<size_t>::max)());
981
989
998 size_t tryThrottle(bool resetWhenDelay = false);
999
1008 Session & throttlingLimit(size_t messagesCount, size_t intervalInMs = 1000);
1009
1018 Session & warmUp(FlatMessage* msg, int warmupFlags = 0);
1019
1029 static bool checkWarmupFlags(int warmupFlags, unsigned short baseListenPort = 5000, const std::string & localNetworkInterface = "127.0.0.1");
1030
1036 void preFill(Message & msg) const;
1037
1047 void preFill(FlatMessage & msg) const;
1048 void preFill(FlatMessageBatch & msgs) const;
1049
1056
1062 operator const std::string & () const;
1063
1069 const std::string & storageId() const;
1070
1079 Session & flushSessionStorage(bool syncData = false);
1080
1089 std::string counterpartyHost() const;
1090
1096 std::string counterpartyIpAddress() const;
1097
1103 size_t counterpartyPort() const;
1104
1110 const std::string & customKey() const;
1111
1117 size_t outboundQueueBytes() const;
1118
1123
1129
1134
1140
1145
1149 typedef std::set<std::string> InboundMessageLogFilter;
1150
1157
1164
1168 typedef std::set<std::string> OutboundMessageLogFilter;
1169
1176
1183
1190 bool logBeforeSending() const;
1191
1198
1205
1212
1219
1226
1231 static const unsigned int ResendRequestMaximumRangeNoLimit;
1232
1243
1253
1260
1267 size_t resendingQueueSize() const;
1268
1275
1281 size_t resendingBatchSize() const;
1282
1289
1295 const std::string & senderCompId() const;
1296
1302
1310
1316
1321
1327
1333 const std::string & targetCompId() const;
1334
1339
1344
1349
1354
1359
1364
1369
1374
1379
1384
1389
1394
1399
1404
1409
1414
1422 Message * findSentMessage(SequenceNumber messageSequenceNumber);
1424
1434
1445
1450
1456
1461
1469
1474
1480
1485
1492
1497
1502
1507
1515
1521
1528
1533
1538
1547
1554
1560 std::string senderSubId() const;
1561
1567 Session & senderSubId(const std::string & value);
1568
1574 std::string targetSubId() const;
1575
1581 Session & targetSubId(const std::string & value);
1582
1588 std::string senderLocationId() const;
1589
1595 Session & senderLocationId(const std::string & value);
1596
1602 std::string targetLocationId() const;
1603
1609 Session & targetLocationId(const std::string & value);
1610
1615
1621
1627 std::string threadNameSuffix() const;
1628
1639 Session & threadNameSuffix(const std::string & value);
1640
1650 Session & sendTestRequest(const std::string & testReqId = "", const TimeSpan & timeout = TimeSpan::zero());
1651
1663
1672 Session & sendReject(SequenceNumber refSeqNumber, const std::string & text);
1673
1681
1687 std::string toString() const;
1688
1693
1700
1707
1716 Session & logDirectory(const std::string & value);
1717
1723 const std::string & logDirectory() const;
1724
1735 Session & resendTimeout(const TimeSpan & timeout);
1736
1743
1747 typedef std::vector<Tag> ScrambledFields;
1748
1755
1760
1768
1773 size_t sendQueueMaxSize() const;
1774
1780 Session & connectTimeout(const TimeSpan & timeout);
1781
1788
1796
1804
1811 int sendBufferSize() const;
1812
1820
1827 bool enableRxTimestamp() const;
1828
1836
1844
1849 {
1851 :host(), port(), username(), password()
1852 {}
1853
1854 ProxySettings(const std::string & proxyHost, int proxyPort, const std::string & proxyUsername = std::string(), const std::string & proxyPassword = std::string())
1855 :host(proxyHost), port(proxyPort), username(proxyUsername), password(proxyPassword)
1856 {}
1857
1858 std::string host;
1859 int port;
1860 std::string username;
1861 std::string password;
1862 };
1863
1868
1873
1878
1883
1884 struct Impl;
1885
1886private:
1887 void init(
1888 const std::string & senderCompId,
1889 const std::string & targetCompId,
1890 const Dictionary & dictionary,
1891 ISessionListener * listener,
1892 bool keepSequenceNumbersAfterLogout,
1893 SessionStorageType::Enum storageType,
1894 ISessionStorage * storage,
1895 const std::string & customSessionKey,
1896 ISessionReactor * reactor);
1897
1898 Impl * impl_;
1899
1900 friend class Engine::Impl;
1901};
1902
1905std::ostream & operator << (std::ostream & os, const Session & session);
1906}
1907}
#define ONIXS_FIXENGINE_API_DECL(typeKind, typeName)
Definition ABI.h:57
#define ONIXS_FIXENGINE_API
Definition ABI.h:45
#define ONIXS_FIXENGINE_NULLPTR
Definition Compiler.h:200
The immutable secure string.
Identifies the FIX messages dictionary.
Definition Dictionary.h:74
The FIX Engine.
Definition Engine.h:41
Provides an access to FIX fields from a flat (tag=value) message.
The session's Listener.
The session's network stack reactor interface.
The session's pluggable storage.
Encapsulates operations over a FIX Message.
Definition Message.h:52
Message batch types.
Definition Session.h:869
const_iterator begin() const
Definition Session.h:896
const MsgType & operator[](size_t index) const
Definition Session.h:892
Traits::MsgBatchType::const_iterator const_iterator
Definition Session.h:884
MsgType & operator[](size_t index)
Definition Session.h:891
void add(MessagePtr &msg)
Definition Session.h:889
const_iterator end() const
Definition Session.h:899
Traits::MessagePtr MessagePtr
Definition Session.h:882
Traits::MsgBatchType::iterator iterator
Definition Session.h:883
The FIX Session - a bi-directional stream of ordered messages between two parties within a continuous...
Definition Session.h:98
InboundMessageLogFilter inboundMessageLogFilter() const
Returns incoming message types to be filtered out from the logs.
Session & send(MessageBatch &msgs, size_t maxPacketSize=(std::numeric_limits< size_t >::max)())
Sends messages in a batch to the counterparty.
SequenceNumber inSeqNum() const
Returns the expected sequence number of the next incoming message.
Session & send(FlatMessageBatch &msgs, SessionSendMode::Enum mode, size_t maxPacketSize=(std::numeric_limits< size_t >::max)())
Performs sending via a specific API (e.g.
std::string localNetworkInterface() const
Returns the local network interface from which you intend to send and receive data.
Session & updateSendingTimeField(bool specify)
The option to specify updating of the SendingTime of every sent message.
Session & sendResendRequestOnEachMessageGap(bool send)
By default, the "Resend Request" message is sent only once - when the first gap is detected.
bool validateSequenceNumbers() const
Returns the current status of the incoming message sequence numbers validation.
SslProtocolMinMaxVersion::Enum sslMaxProtocolVersion() const
Returns the maximal SSL/TLS protocol version that will be declared during the SSL/TLS handshake.
Session & sendingThreadAffinity(const OnixS::Threading::CpuIndexes &cpuIndexes)
Sets the CPU affinity index of the sending thread.
int heartbeatIntervalSec() const
Returns the Heartbeat interval (in seconds).
Session & sendSpinningTimeoutUsec(int usec)
Sets the send spinning timeout (in microseconds) of the Session::send(..) method to wait for the sock...
bool updateSendingTimeField() const
Returns 'true' if updating of the SendingTime is turn on for every message, otherwise - 'false'.
Session & logOutboundMessages(bool value)
The option to log outbound messages.
~Session()
The destructor.
Session & shutdown()
Shutdowns the session.
int reasonableTransmissionTime() const
Returns the reasonable transmission time as % from the heartbeatIntervalSec value.
Session & receivingThreadAffinity(const OnixS::Threading::CpuIndexes &cpuIndexes)
Sets the CPU affinity of the receiving thread.
Session & throttle()
Performs the throttling of a session that must be called before each send function call.
TimeSpan resendTimeout() const
Returns the timeout during which the counterparty should send a reply to the "Resend Request" message...
Session & targetSubId(const std::string &value)
Sets the TargetSubID (tag 57) field values for all outgoing messages.
int listenPort() const
Returns the port to listen on for incoming FIX Connections in the Acceptor mode.
Session & validateSequenceNumbers(bool value)
Options to turn on/off incoming message sequence numbers validation.
MsgBatchTraits< Message >::MsgBatchType findSentMessages(SequenceNumber beginSequenceNumber, SequenceNumber endSequenceNumber)
Returns an array of sent messages if it can be found by the given message sequence number range,...
Session & sendTestRequest(const std::string &testReqId="", const TimeSpan &timeout=TimeSpan::zero())
Sends the Test Request (MsgType 1) message.
Session & reconnectInterval(int value)
Sets the time interval between the attempts to restore the FIX connection (in seconds).
int reconnectInterval() const
Returns the time interval between the attempts to restore the FIX connection (in seconds).
const OnixS::Threading::CpuIndexes & sendingThreadAffinity() const
Returns the CPU affinity of the sending thread.
Session & sslMinProtocolVersion(SslProtocolMinMaxVersion::Enum version)
Sets the minimal SSL/TLS protocol version that will be declared during the SSL/TLS handshake.
Session & warmUp(FlatMessage *msg, int warmupFlags=0)
This method warms up the sending path.
std::string toString() const
Returns the session string presentation.
Session & sendingThreadAffinity(const OnixS::Threading::CpuIndex cpuIndex)
Sets the CPU affinity index of the sending thread a CPU.
friend class Engine::Impl
Definition Session.h:1900
Session & messageGrouping(unsigned numberOfMessagesToGroup)
Sets the number of messages that should be written to the outgoing TCP buffer together.
MessageMode::Enum messageMode() const
Returns the session message mode.
Session & breakConnection()
Terminates the FIX connection in the non-graceful way (without the exchange of Logout (MsgType=5) mes...
bool ignoreLessThanExpectedSequenceNumber() const
Returns 'true' if the sequence number of the incoming message, which less than expected,...
std::string sslPrivateKeyFile() const
Returns the SSL private key file.
size_t sendQueueMaxSize() const
Returns the send queue maximum size in bytes.
Session & sslClientSni(const std::string &hostName)
Sets the client-side SNI-extension field.
Session & inSeqNum(SequenceNumber seqNum)
Sets the expected sequence number of the next incoming message.
int reconnectAttempts() const
Returns the number of attempts to restore the FIX connection.
Session & logBeforeSending(bool value)
The option to switch on/off the logging of outbound messages before/after sending.
Session & proxySettings(const ProxySettings &settings)
Sets HTTP proxy settings.
Session & scrambleLogonFields(const ScrambledFields &fields)
Sets scrambled fields in the Logon(A) message, in the session storage, for security reasons.
Session & sendAsIs(FlatMessageBatch &msgs, size_t maxPacketSize=(std::numeric_limits< size_t >::max)())
Sends a serialized message(s) to the counterparty without any fields updating.
Session & resendRequestMaximumRange(int range)
Sets the maximum number of messages to be requested in one Resend Request (MsgType=2) message.
Session & sslCaFile(const std::string &value)
Sets the path to the trusted certification authority certificate file in (Privacy Enhanced Mail) Base...
Session & sendReject(SequenceNumber refSeqNumber, const std::string &text)
Sends the Reject (MsgType 3) message.
Session & logout()
Terminates the FIX Connection.
bool validateFieldValues() const
Returns the option to validate the field values of FIX messages in accordance with the FIX protocol o...
bool requestOnlyMissedMessages() const
Returns 'true' if the "Resend Request" message requests only missed messages, otherwise - 'false'.
Session & clearOutboundQueue(bool removeFragmentedPacket=false)
Removes all messages from the outbound queue.
bool enableRxTimestamp() const
Returns the value of the option to enable received data timestamp.
bool considerRejectOnResendRequestAsGapFill() const
Returns 'true' if the "Reject" on the "Resend Request" is considered as the "Sequence Reset Gap Fill"...
Session & supportNextExpectedMsgSeqNum(bool support)
Sets the NextExpectedMsgSeqNum field (tag 789) support in Logon messages.
std::string senderLocationId() const
Returns the SenderLocationID (tag 142) field values for all outgoing messages.
OutboundMessageLogFilter outboundMessageLogFilter() const
Returns outgoing message types to be filtered out from the logs.
Session & resetSeqNumViaLogonExchange()
Sends a Logon message with the ResetSeqNumFlag set.
Session & validateFieldValues(bool)
Sets the option to validate the field values of FIX messages in accordance with the FIX protocol or i...
Dictionary dictionary() const
The instance of the FIX dictionary or standard FIX messages dictionary which is used by the session.
Session & validateEmptyFieldValues(bool)
Sets the option to validate the empty field values of FIX messages in accordance with the FIX protoco...
Session & useSpinLock(bool value)
Sets the Session to use the spin lock.
Session(const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, bool keepSequenceNumbersAfterLogout, OnixS::FIX::ISessionListener *listener, const std::string &customSessionKey, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=ONIXS_FIXENGINE_NULLPTR)
Creates the FIX Session.
Session & outboundMessageLogFilter(const OutboundMessageLogFilter &filter)
Sets outgoing message types to be filtered out from the logs.
std::vector< Tag > ScrambledFields
The collection of scrambled tags.
Definition Session.h:1747
Session & socketOptions(const OnixS::Sockets::SocketOptions &options)
Additional options, which should be set to the session socket when it is created.
Session & validateUnknownMessages(bool)
Sets the option to validate the presence of unknown FIX messages.
Session & listenPort(int listenPort)
Sets the port to listen on for incoming FIX Connections in the Acceptor mode.
size_t outboundQueueBytes() const
Returns the total number of bytes in the outbound queue.
bool reportNewMessagesWhileWaitingForMissedMessages() const
Returns 'true' if the new messages are reported even when the message gap is detected and the reply o...
Session(ISessionReactor *reactor, const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, bool keepSequenceNumbersAfterLogout, OnixS::FIX::ISessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=ONIXS_FIXENGINE_NULLPTR)
Creates the FIX Session.
Session & localPortRange(LocalPortRange portRange)
Sets the local port range, the first available port from this range will be used to send and receive ...
Session & logonAsAcceptor()
Establishes the FIX Connection as an Acceptor.
SslProtocolMinMaxVersion::Enum sslMinProtocolVersion() const
Returns the minimal SSL/TLS protocol version that will be declared during the SSL/TLS handshake.
Session & throttlingLimit(size_t messagesCount, size_t intervalInMs=1000)
Sets throttling limit parameters.
Session & tcpNoDelayOption(bool improveLatency=true)
Sets the value of the option to improve the latency at the expense of the message throughput (TCP_NOD...
Session & sslCertificateFile(const std::string &file)
Sets the SSL certificate file.
size_t resendingQueueSize() const
Returns the number of sent messages that are available for resending on the counterparty's Resend Req...
MsgBatchTraits< FlatMessage >::MsgBatchType findSentFlatMessages(SequenceNumber beginSequenceNumber, SequenceNumber endSequenceNumber)
bool validateRepeatingGroupEntryCount() const
Returns the option that controls the repeating group entry count validation.
static const unsigned int ResendRequestMaximumRangeNoLimit
Represents an unlimited number of messages to be requested in one Resend Request (MsgType=2) message.
Definition Session.h:1231
int receiveBufferSize() const
Returns the size of the TCP buffer allocated to the FIX connection for receiving data.
bool validateChecksum() const
Returns the option that controls the validation of the checksum of the incoming message.
Session & unregisterListener(ISessionListener *listener)
Unregisters the Session listener.
Session & logonAsInitiator(const std::string &host, int port, int heartbeatIntervalSec, bool setResetSeqNumFlag)
Establishes the FIX Connection as an Initiator using the given Heartbeat interval (seconds) and the R...
Session & logonAsInitiator(const std::string &host, int port, int heartbeatIntervalSec, Message *customLogonMsg, bool setResetSeqNumFlag)
Establishes the FIX Connection as an Initiator using the custom Logon message and the ResetSeqNumFlag...
Session & sendAsIs(FlatMessage *msg)
Sends a serialized message(s) to the counterparty without any fields updating.
void messageMode(MessageMode::Enum mode)
Sets the session message mode.
Session & enableRxTimestamp(bool value)
Sets the value of the option to enable received data timestamp.
int sendBufferSize() const
Returns the size of the TCP buffer allocated to the FIX connection for the sending data.
Session & sendingTimeFormat(TimestampFormat::Enum format)
Sets the time format of the SendingTime of every sent message.
Session & logonAsInitiator(const std::string &host, int port)
Establishes the FIX Connection as an Initiator.
Session(ISessionReactor *reactor, const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, ISessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=ONIXS_FIXENGINE_NULLPTR)
Creates the FIX Session.
int receivingThreadPolicy() const
Returns the scheduling policy of the receiving thread.
Session & receiveSpinningTimeoutUsec(int usec)
Sets the non-blocking receive spinning timeout (in microseconds) before the receiving thread enters i...
std::set< std::string > OutboundMessageLogFilter
Outgoing message types to be filtered out from the logs.
Definition Session.h:1168
Session & requestOnlyMissedMessages(bool request)
By default, the "Resend Request" message requests all messages begin from the first missed one.
size_t incomingMessageGapQueueMaximumSize() const
Returns the maximum size of the incoming message gap queue.
Session(const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, bool keepSequenceNumbersAfterLogout, OnixS::FIX::ISessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=ONIXS_FIXENGINE_NULLPTR)
Creates the FIX Session.
Cryptography::SecureString sslPrivateKeyPassword() const
Returns the SSL private key file password.
Session & send(FlatMessageBatch &msgs, size_t maxPacketSize=(std::numeric_limits< size_t >::max)())
Session & sendingThreadPolicy(int policy)
Sets the scheduling policy of the sending thread.
Session & validateRepeatingGroupEntryCount(bool)
Sets the value of the option that controls the repeating group entry count validation.
size_t tryThrottle(bool resetWhenDelay=false)
Checks the throttling of a session that must be called before each send function call.
Session & logout(FlatMessage *customLogoutMessage)
bool sendResendRequestOnEachMessageGap() const
Returns 'true' if the "Resend Request" message is sent on each detected message sequence number gap,...
Session & sendLogoutOnException(bool sendLogoutOnException)
Sets the value of the option that controls whether to send the logout message before dropping the tel...
EncryptionMethod::Enum encryptionMethod() const
Returns the current encryption method.
const OnixS::Threading::CpuIndexes & receivingThreadAffinity() const
Returns the CPU affinity of the receiving thread.
const std::string & senderCompId() const
Returns the assigned value used to identify the firm sending message (the SenderCompID (tag 49) field...
const std::string & sslClientSni() const
Returns the client-side SNI-extension field.
Session & flushSessionStorage(bool syncData=false)
Flushes all internal buffers of the underlying storage.
Session & resendTimeout(const TimeSpan &timeout)
Sets the timeout during which counterparty should send a reply to the "Resend Request" message.
std::pair< unsigned short, unsigned short > LocalPortRange
The local port range type.
Definition Session.h:299
std::string sslCaFile() const
Returns the path to the trusted certification authority certificate file in the (Privacy Enhanced Mai...
Session & logInboundMessages(bool value)
The option to log inbound messages.
static const OnixS::Sockets::Handle InvalidSocketHandle
Represents an invalid value of the socket handle.
Definition Session.h:1692
Threading::SharedFuture< void > logoutAsync(FlatMessage *customLogoutMessage)
bool logInboundMessages() const
Returns 'true' if inbound messages are logged, otherwise - 'false'.
ScrambledFields scrambleLogonFields() const
Returns scrambled fields in the Logon(A) message.
Session & logout(Message *customLogoutMessage)
Terminates the FIX Connection.
Session & logonAsInitiator(const std::string &host, int port, int heartbeatIntervalSec, Message *customLogonMsg)
Establishes the FIX Connection as an Initiator using the custom Logon message.
Session & send(FlatMessage *msg)
Session & threadingModel(ThreadingModel::Enum value)
Sets the connection mode.
FlatMessageBatch SerializedMessageBatch
Definition Session.h:905
std::string targetLocationId() const
Returns the TargetLocationID (tag 143) field values for all outgoing messages.
bool sslVerifyPeer() const
Returns the option to request peer certificates and perform the certificate verification.
unsigned short localPort() const
Returns the local port from which you intend to send and receive data.
Timestamp creationTime() const
Returns the time when logical session was created or the last sequence number reset operation was per...
Session(const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, ISessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=ONIXS_FIXENGINE_NULLPTR)
Creates the FIX Session.
Session & logonAsInitiator(const std::string &host, int port, int heartbeatIntervalSec)
Establishes the FIX Connection as an Initiator using the given Heartbeat interval (seconds).
std::string threadNameSuffix() const
Returns the thread name suffix for receiving (R:threadNameSuffix) and sending (S:threadNameSuffix) th...
Session & sslPrivateKeyFile(const std::string &file)
Sets the SSL private key file.
bool logOutboundMessages() const
Returns 'true' if outbound messages are logged, otherwise - 'false'.
const std::string & logDirectory() const
Inbound and outbound messages, the session's state data are stored in this directory.
Session & receivingThreadPriority(int priority)
Sets the priority of the receiving thread.
ThreadingModel::Enum threadingModel() const
Returns the connection mode.
Session & validateRequiredFields(bool)
Sets the option to validate the presence of required fields in inbound and outbound messages.
void preFill(FlatMessage &msg) const
Pre-fills the following fields in the message or messages batch for sending as is:
Session & sendBufferSize(int value)
Sets the size of the TCP buffer allocated to the FIX connection for the sending data.
const std::string & customKey() const
Returns the Session's Custom Key.
Session & validateDuplicatedField(bool)
Sets value of the option that controls the duplicated field validation.
LocalPortRange localPortRange() const
Returns the local port range, the first available port from this range will be used to send and recei...
Session & sendQueueMaxSize(size_t size)
Sets the send queue maximum size in bytes.
Session & logout(const std::string &text)
Terminates the FIX Connection.
Session & logonAsInitiator(const std::string &host, int port, bool setResetSeqNumFlag)
Establishes the FIX Connection as an Initiator using the ResetSeqNumFlag (tag 141) field.
unsigned messageGrouping() const
Returns the number of messages that should be written to the outgoing TCP buffer together.
Session & incomingMessageGapQueueMaximumSize(size_t maxSize)
If the requestOnlyMissedMessages option is true and the sequence number of an incoming FIX message gr...
int sendingThreadPriority() const
Returns the priority of the sending thread.
Session & receiveBufferSize(int value)
Sets the size of the TCP buffer allocated to the FIX connection for the receiving data.
Message * findSentMessage(SequenceNumber messageSequenceNumber)
Returns the sent message if it can be found by the given message sequence number, otherwise - NULL.
bool resetLocalSequenceNumbersOnLogon() const
Returns 'true' if local sequence numbers are reset automatically to 1 during every logon,...
Session & validateUnknownFields(bool)
Sets the option to validate the presence of unknown fields.
Session & unregisterAllListeners()
Unregisters all Session listener.
Session & ignoreLessThanExpectedSequenceNumber(bool ignore)
By default, if the incoming message has a sequence number less than expected and the PossDupFlag is n...
SequenceNumber outSeqNum() const
Returns the sequence number of the next outgoing message.
int sendSpinningTimeout() const
Returns the current send spinning timeout value (in microseconds).
Session & threadNameSuffix(const std::string &value)
Sets the thread name suffix for receiving ("R:threadNameSuffix") and sending ("S:threadNameSuffix") t...
MsgBatch< Message > MessageBatch
Definition Session.h:903
Session & targetLocationId(const std::string &value)
Sets the TargetLocationID (tag 143) field values for all outgoing messages.
bool specifyLastMsgSeqNumProcessed() const
Returns 'true' if the LastMsgSeqNumProcessed (tag 369) field is specified on every message sent,...
Session & sslMaxProtocolVersion(SslProtocolMinMaxVersion::Enum version)
Sets the maximal SSL/TLS protocol version that will be declared during the SSL/TLS handshake.
Session & specifyLastMsgSeqNumProcessed(bool specify)
The option to specify the LastMsgSeqNumProcessed (tag 369) field on every message sent.
FlatMessage * findSentFlatMessage(SequenceNumber messageSequenceNumber)
Session & senderSubId(const std::string &value)
Sets the SenderSubID (tag 50) field values for all outgoing messages.
void preFill(Message &msg) const
Pre-fills session-level fields that are constant during the session's lifetime - SenderCompId,...
OnixS::Sockets::Handle socketHandle()
Returns the socket handle which the session uses to transmit the FIX data.
Session & resetLocalSequenceNumbersOnLogon(bool reset)
The option to automatically reset the local sequence numbers to 1 during every logon.
size_t resendingBatchSize() const
Returns the maximum number of messages sent in reply to the Resend Request <2> before temporarily rel...
Session & receivingThreadPolicy(int policy)
Sets the scheduling policy of the receiving thread.
std::string counterpartyHost() const
Returns the counterparty host name.
SessionState::Enum state() const
Returns the Session's state.
bool logBeforeSending() const
Returns 'true' if outbound messages are logged before sending, otherwise - 'false'.
Threading::SharedFuture< void > logoutAsync(const std::string &text)
Terminates the FIX Connection.
MsgBatch< FlatMessage > FlatMessageBatch
Definition Session.h:904
std::string senderSubId() const
Returns the SenderSubID (tag 50) field values for all outgoing messages.
Session & sendResendRequest(SequenceNumber beginSeqNumber)
Sends the Resend Request (MsgType 2) message.
Session & outSeqNum(SequenceNumber seqNum)
Sets the sequence number of the next outgoing message.
Session & inboundMessageLogFilter(const InboundMessageLogFilter &filter)
Sets incoming message types to be filtered out from the logs.
TimeSpan connectTimeout() const
Returns the socket TCP connect timeout (30 sec by default).
SessionRole::Enum role() const
Returns the session role.
Threading::SharedFuture< void > logonAsInitiatorAsync(const std::string &host, int port, int heartbeatIntervalSec, Message *customLogonMsg, bool setResetSeqNumFlag)
Establishes the FIX Connection asynchronously as an Initiator using the custom Logon message and the ...
Session & resendingQueueSize(size_t value)
Sets the number of sent messages that are available for resending on the counterparty's Resend Reques...
Session & send(FlatMessage *msg, SessionSendMode::Enum mode)
Performs sending via a specific API (e.g.
Session & validateRepeatingGroupLeadingTag(bool)
Sets the value of the option that controls the repeating group leading tag validation.
Session & reasonableTransmissionTime(int value)
Sets the reasonable transmission time as % from the heartbeatIntervalSec value.
Session & encryptionMethod(EncryptionMethod::Enum newEncryptionMethod)
Sets the encryption method.
bool validateRequiredFields() const
Returns the option to validate the presence of required fields in inbound and outbound messages.
Session(ISessionReactor *reactor, const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, bool keepSequenceNumbersAfterLogout, OnixS::FIX::ISessionListener *listener, const std::string &customSessionKey, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=ONIXS_FIXENGINE_NULLPTR)
Creates the FIX Session.
bool sendLogoutOnException() const
Returns the option that controls whether to send the logout message before dropping the telecommunica...
int receiveSpinningTimeout() const
Returns the current receive spinning timeout value (in microseconds).
int receivingThreadPriority() const
Returns the priority of the receiving thread.
Session & receivingThreadAffinity(const OnixS::Threading::CpuIndex cpuIndex)
Sets the CPU affinity of the receiving thread to a CPU.
Session & reconnectAttempts(int value)
Sets the number of attempts to restore the FIX connection.
Session & senderLocationId(const std::string &value)
Sets the SenderLocationID (tag 142) field values for all outgoing messages.
Session & logDirectory(const std::string &value)
Inbound and outbound messages, the session's state data are stored in this directory.
const std::string & targetCompId() const
Returns the assigned value used to identify the receiving firm (the TargetCompID (tag 56) field value...
Threading::SharedFuture< void > logoutAsync(Message *customLogoutMessage)
Terminates the FIX Connection.
const std::string & storageId() const
Returns the underlying storage Id.
std::string targetSubId() const
Returns the TargetSubID (tag 57) field values for all outgoing messages.
ProxySettings proxySettings() const
Returns HTTP proxy settings.
bool validateDuplicatedField() const
Returns the option that controls the duplicated field validation.
Session & sslPrivateKeyPassword(const Cryptography::SecureString &password)
Sets the SSL private key file password.
Session & validateChecksum(bool)
Sets the validation of the checksum of the incoming message.
Session & connectTimeout(const TimeSpan &timeout)
Sets the socket TCP connect timeout.
Session & reportNewMessagesWhileWaitingForMissedMessages(bool report)
When the message gap is detected the "Resend Request" FIX Message is sent and the Session state is ch...
size_t counterpartyPort() const
Returns the counterparty port number.
Session & registerListener(ISessionListener *listener)
Registers the Session listener.
Session & resendingBatchSize(size_t value)
Sets the maximum number of messages sent in reply to the Resend Request <2> before temporarily releas...
Session & sslVerifyPeer(bool verify)
Set the option to request peer certificates and perform the certificate verification.
int resendRequestMaximumRange() const
Returns the maximum number of messages to be requested in one Resend Request (MsgType=2) message.
Session & localNetworkInterface(const std::string &localNetworkInterface)
Sets the local network interface from which you intend to send and receive data.
std::string sslCertificateFile() const
Returns the SSL certificate file.
bool validateEmptyFieldValues() const
Returns the option to validate the empty field values of FIX messages in accordance with the FIX prot...
void preFill(FlatMessageBatch &msgs) const
static const int UndefinedPriorityAndPolicy
Represents an undefined value of priority and policy.
Definition Session.h:1373
std::set< std::string > InboundMessageLogFilter
Incoming message types to be filtered out from the logs.
Definition Session.h:1149
static bool checkWarmupFlags(int warmupFlags, unsigned short baseListenPort=5000, const std::string &localNetworkInterface="127.0.0.1")
Returns 'true' if the given flags work as expected and a real data is not sent to the wire,...
bool supportNextExpectedMsgSeqNum() const
Returns 'true' if the NextExpectedMsgSeqNum field (tag 789) is supported in Logon messages,...
int sendingThreadPolicy() const
Returns the scheduling policy of the sending thread.
bool validateUnknownMessages() const
Returns the option to validate the presence of unknown FIX messages.
std::string counterpartyIpAddress() const
Returns the counterparty address.
bool tcpNoDelayOption() const
Returns the option to improve the latency at the expense of the message throughput (TCP_NODELAY socke...
Session & considerRejectOnResendRequestAsGapFill(bool consider)
By default, if the "Session Level Reject" message is received in replay to the "Resend Request" then ...
bool useSpinLock() const
Returns whether the Session uses the spin lock.
Session & resetLocalSequenceNumbers()
Backups the current log files and resets the local sequence numbers to 1.
bool validateRepeatingGroupLeadingTag() const
Returns the option that controls the repeating group leading tag validation.
Session & sendingThreadPriority(int priority)
Sets the priority of the sending thread.
void scheduleShrinkToFit()
Schedule the memory usage optimization.
Session & send(Message *msg)
Sends the message to the counterparty.
bool validateUnknownFields() const
Returns the option to validate the presence of unknown fields.
The time span related functionality.
Definition TimeSpan.h:94
static TimeSpan zero()
The zero value of the time span.
The timestamps related functionality.
Definition Timestamp.h:92
Represents a future result of an asynchronous operation - a result that will eventually appear in the...
Definition Future.h:254
ONIXS_FIXENGINE_API std::ostream & operator<<(std::ostream &os, const Group &group)
Stream output.
unsigned int SequenceNumber
Alias for the sequence number.
std::vector< SocketOption > SocketOptions
Storage type of socket options.
Definition Definitions.h:67
int Handle
Type alias for socket handle.
Definition Definitions.h:50
size_t CpuIndex
Logical processors that a thread is allowed to run on (first logical CPU has index 0).
Definition Thread.h:31
std::set< CpuIndex > CpuIndexes
Definition Thread.h:32
The session message mode.
Definition Session.h:62
@ FlatMessage
The FlatMessage class is used in inbound callbacks.
Definition Session.h:68
@ Message
The default mode. The Message class is used in inbound callbacks.
Definition Session.h:65
std::vector< FlatMessage * > MsgBatchType
Definition Session.h:82
std::vector< OnixS::FIX::Core::Messaging::Extras::FlatMessage * > CoreMsgBatchType
Definition Session.h:83
PtrTraits< MsgType >::UniquePtr MessagePtr
Definition Session.h:81
@ FileBased
The file based storage. The session's state and messages are persisted to the file system.
ProxySettings(const std::string &proxyHost, int proxyPort, const std::string &proxyUsername=std::string(), const std::string &proxyPassword=std::string())
Definition Session.h:1854
std::auto_ptr< T > UniquePtr
Definition Definitions.h:32