OnixS C++ FIX Engine  4.0.0
API Documentation
Session Class Reference

#include <OnixS/FIXEngine/FIX/Session.h>

Public Types

typedef std::pair< unsigned short, unsigned short > LocalPortRange
 
typedef std::vector< Message * > MessageBatch
 
typedef std::vector< OnixS::FIX::SerializedMessage * > SerializedMessageBatch
 
typedef std::set< std::string > InboundMessageLogFilter
 
typedef std::set< std::string > OutboundMessageLogFilter
 

Public Member Functions

 Session (const std::string &senderCompId, const std::string &targetCompId, const Dictionary &dictionary, ISessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, ISessionStorage *storage=NULL)
 
 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=NULL)
 
 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=NULL)
 
 ~Session ()
 
void clearOutboundQueue (bool removeFragmentedPacket=false)
 
SessionState::Enum state () const
 
EncryptionMethod::Enum encryptionMethod () const
 
void encryptionMethod (EncryptionMethod::Enum newEncryptionMethod)
 
int listenPort () const
 
void listenPort (int listenPort)
 
const std::string & localNetworkInterface () const
 
void localNetworkInterface (const std::string &localNetworkInterface)
 
unsigned short localPort () const
 
LocalPortRange localPortRange () const
 
void localPortRange (LocalPortRange portRange)
 
bool tcpNoDelayOption () const
 
void tcpNoDelayOption (bool improveLatency=true)
 
bool sendLogoutOnException () const
 
void sendLogoutOnException (bool sendLogoutOnException)
 
bool validateUnknownMessages () const
 
void validateUnknownMessages (bool)
 
bool validateUnknownFields () const
 
void validateUnknownFields (bool)
 
bool validateRequiredFields () const
 
void validateRequiredFields (bool)
 
bool validateFieldValues () const
 
void validateFieldValues (bool)
 
bool validateEmptyFieldValues () const
 
void validateEmptyFieldValues (bool)
 
bool validateRepeatingGroupEntryCount () const
 
void validateRepeatingGroupEntryCount (bool value)
 
bool validateRepeatingGroupLeadingTag () const
 
void validateRepeatingGroupLeadingTag (bool value)
 
bool validateDuplicatedField () const
 
void validateDuplicatedField (bool value)
 
unsigned messageGrouping () const
 
void messageGrouping (unsigned numberOfMessagesToGroup)
 
ConnectionMode::Enum connectionMode () const
 
void connectionMode (ConnectionMode::Enum value)
 
int reasonableTransmissionTime () const
 
void reasonableTransmissionTime (int value)
 
void reconnectAttempts (int value)
 
int reconnectAttempts () const
 
void reconnectInterval (int value)
 
int reconnectInterval () const
 
void receiveSpinningTimeoutUsec (int usec)
 
int receiveSpinningTimeout () const
 
void sendSpinningTimeoutUsec (int usec)
 
int sendSpinningTimeout () const
 
void supportNextExpectedMsgSeqNum (bool support)
 
bool supportNextExpectedMsgSeqNum () const
 
std::string sslCertificateFile () const
 
void sslCertificateFile (const std::string &file)
 
std::string sslPrivateKeyFile () const
 
void sslPrivateKeyFile (const std::string &file)
 
std::string sslPrivateKeyPassword () const
 
void sslPrivateKeyPassword (const std::string &password)
 
void sslVerifyPeer (bool verify)
 
bool sslVerifyPeer () const
 
void sslCaFile (const std::string &value)
 
std::string sslCaFile () const
 
void logonAsAcceptor ()
 
void logonAsInitiator (const std::string &host, int port, bool setResetSeqNumFlag)
 
void logonAsInitiator (const std::string &host, int port)
 
void logonAsInitiator (const std::string &host, int port, int heartbeatIntervalSec)
 
void logonAsInitiator (const std::string &host, int port, int heartbeatIntervalSec, bool setResetSeqNumFlag, bool async=false)
 
void logonAsInitiator (const std::string &host, int port, int heartbeatIntervalSec, Message *customLogonMsg)
 
void logonAsInitiator (const std::string &host, int port, int heartbeatIntervalSec, Message *customLogonMsg, bool setResetSeqNumFlag, bool async=false)
 
void logout ()
 
void logout (const std::string &text, bool async=false)
 
void logout (Message *customLogoutMessage, bool async=false)
 
void logout (OnixS::FIX::Core::Messaging::Extras::SerializedMessage *customLogoutMessage, bool async=false)
 
void breakConnection ()
 
void send (Message *msg)
 
void send (OnixS::FIX::SerializedMessage *msg)
 
void send (OnixS::FIX::SerializedMessage *msg, SessionSendMode::Enum mode)
 
void send (const MessageBatch &msgs)
 
void send (const SerializedMessageBatch &msgs)
 
void sendAsIs (OnixS::FIX::SerializedMessage *msg)
 
void sendAsIs (const SerializedMessageBatch &msgs)
 
void throttle ()
 
void throttlingLimit (size_t messagesCount, size_t intervalInMs=1000)
 
void warmUp (OnixS::FIX::SerializedMessage *msg, int warmupFlags=0)
 
void preFill (Message &msg) const
 
void preFill (OnixS::FIX::SerializedMessage &msg) const
 
void preFill (SerializedMessageBatch &msgs) const
 
void shutdown ()
 
 operator const std::string & () const
 
const std::string & storageId () const
 
void flushSessionStorage ()
 
std::string counterpartyHost () const
 
std::string counterpartyIpAddress () const
 
size_t counterpartyPort () const
 
const std::string & customKey () const
 
size_t outboundQueueBytes () const
 
int heartbeatIntervalSec () const
 
bool logInboundMessages () const
 
void logInboundMessages (bool value)
 
bool logOutboundMessages () const
 
void logOutboundMessages (bool value)
 
InboundMessageLogFilter inboundMessageLogFilter () const
 
void inboundMessageLogFilter (const InboundMessageLogFilter &filter)
 
OutboundMessageLogFilter outboundMessageLogFilter () const
 
void outboundMessageLogFilter (const OutboundMessageLogFilter &filter)
 
SequenceNumber inSeqNum () const
 
void inSeqNum (SequenceNumber seqNum)
 
SequenceNumber outSeqNum () const
 
void outSeqNum (SequenceNumber seqNum)
 
void resendRequestMaximumRange (int range)
 
int resendRequestMaximumRange () const
 
void resendingQueueSize (int value)
 
int resendingQueueSize () const
 
SessionRole::Enum role () const
 
const std::string & senderCompId () const
 
bool specifyLastMsgSeqNumProcessed () const
 
void specifyLastMsgSeqNumProcessed (bool specify)
 
bool updateSendingTimeField () const
 
void updateSendingTimeField (bool specify)
 
void sendingTimeFormat (TimestampFormat::Enum format)
 
const std::string & targetCompId () const
 
Dictionary dictionary () const
 
const OnixS::Threading::CpuIndexesreceivingThreadAffinity () const
 
void receivingThreadAffinity (const OnixS::Threading::CpuIndexes &cpuIndexes)
 
void receivingThreadAffinity (const OnixS::Threading::CpuIndex cpuIndex)
 
const OnixS::Threading::CpuIndexessendingThreadAffinity () const
 
void sendingThreadAffinity (const OnixS::Threading::CpuIndexes &cpuIndexes)
 
void sendingThreadAffinity (const OnixS::Threading::CpuIndex cpuIndex)
 
int receivingThreadPriority () const
 
void receivingThreadPriority (int priority)
 
int sendingThreadPriority () const
 
void sendingThreadPriority (int priority)
 
int receivingThreadPolicy () const
 
void receivingThreadPolicy (int policy)
 
int sendingThreadPolicy () const
 
void sendingThreadPolicy (int policy)
 
MessagefindSentMessage (SequenceNumber messageSequenceNumber)
 
void reportNewMessagesWhileWaitingForMissedMessages (bool report)
 
bool reportNewMessagesWhileWaitingForMissedMessages () const
 
void sendResendRequestOnEachMessageGap (bool send)
 
bool sendResendRequestOnEachMessageGap () const
 
void requestOnlyMissedMessages (bool request)
 
bool requestOnlyMissedMessages () const
 
void considerRejectOnResendRequestAsGapFill (bool consider)
 
bool considerRejectOnResendRequestAsGapFill () const
 
void ignoreLessThanExpectedSequenceNumber (bool ignore)
 
bool ignoreLessThanExpectedSequenceNumber () const
 
void resetLocalSequenceNumbersOnLogon (bool reset)
 
bool resetLocalSequenceNumbersOnLogon () const
 
void incomingMessageGapQueueMaximumSize (size_t maxSize)
 
size_t incomingMessageGapQueueMaximumSize () const
 
void registerListener (ISessionListener *listener)
 
void unregisterListener (ISessionListener *listener)
 
void unregisterAllListeners ()
 
void resetLocalSequenceNumbers ()
 
void resetSeqNumViaLogonExchange ()
 
std::string senderSubId () const
 
void senderSubId (const std::string &value)
 
std::string targetSubId () const
 
void targetSubId (const std::string &value)
 
std::string senderLocationId () const
 
void senderLocationId (const std::string &value)
 
std::string targetLocationId () const
 
void targetLocationId (const std::string &value)
 
void validateSequenceNumbers (bool value)
 
bool validateSequenceNumbers () const
 
std::string threadNameSuffix () const
 
void threadNameSuffix (const std::string &value)
 
void sendTestRequest (const std::string &testReqId="")
 
void sendResendRequest (SequenceNumber beginSeqNumber)
 
void sendReject (SequenceNumber refSeqNumber, const std::string &text)
 
Timestamp creationTime () const
 
std::string toString () const
 
OnixS::Sockets::Handle socketHandle ()
 
void socketOptions (const OnixS::Sockets::SocketOptions &options)
 
void logDirectory (const std::string &value)
 
const std::string & logDirectory () const
 

Static Public Member Functions

static bool checkWarmupFlags (int warmupFlags, unsigned short baseListenPort=5000, const std::string &localNetworkInterface="127.0.0.1")
 

Static Public Attributes

static const unsigned int ResendRequestMaximumRangeNoLimit
 
static const int UndefinedPriorityAndPolicy
 
static const OnixS::Sockets::Handle InvalidSocketHandle
 

Friends

class Engine::Impl
 

Detailed Description

Definition at line 57 of file Session.h.

Member Typedef Documentation

typedef std::set<std::string> InboundMessageLogFilter

Incoming message types to be filtered out from the logs.

Definition at line 817 of file Session.h.

typedef std::pair<unsigned short, unsigned short> LocalPortRange

Local port range type.

Definition at line 192 of file Session.h.

typedef std::vector<Message *> MessageBatch

Message batch types.

Definition at line 635 of file Session.h.

typedef std::set<std::string> OutboundMessageLogFilter

Outgoing message types to be filtered out from the logs.

Definition at line 836 of file Session.h.

Definition at line 636 of file Session.h.

Constructor & Destructor Documentation

Session ( const std::string &  senderCompId,
const std::string &  targetCompId,
const Dictionary dictionary,
ISessionListener listener,
SessionStorageType::Enum  storageType = SessionStorageType::FileBased,
ISessionStorage storage = NULL 
)

Creates the FIX Session.

Parameters
senderCompIdAssigned value used to identify firm sending message (SenderCompID (tag=49) field value in outgoing messages).
targetCompIdAssigned value used to identify receiving firm (TargetCompID (tag=56) field value in outgoing messages).
dictionaryFIX dictionary to be used by the session.
listenerInstance of ISessionListener interface which will receive and handle miscellaneous Session events.
storageTypeSession storage type.
storagePluggable Session storage.
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 = NULL 
)

Creates the FIX Session.

Parameters
senderCompIdAssigned value used to identify firm sending message (SenderCompID (tag=49) field value in outgoing messages).
targetCompIdAssigned value used to identify receiving firm (TargetCompID (tag=56) field value in outgoing messages).
dictionaryFIX dictionary to be used by the session.
keepSequenceNumbersAfterLogoutOption to keep sequence numbers after the exchange of Logout (MsgType=5) messages.
listenerInstance of ISessionListener interface which will receive and handle miscellaneous Session events.
storageTypeSession storage type.
storagePluggable Session storage.
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 = NULL 
)

Creates the FIX Session.

Parameters
senderCompIdAssigned value used to identify firm sending message (SenderCompID (tag=49) field value in outgoing messages).
targetCompIdAssigned value used to identify receiving firm (TargetCompID (tag=56) field value in outgoing messages).
dictionaryFIX dictionary to be used by the session.
keepSequenceNumbersAfterLogoutOption to keep sequence numbers after the exchange of Logout (MsgType=5) messages.
listenerInstance of ISessionListener interface which will receive and handle miscellaneous Session events.
customSessionKeyCustom key that can be used to distinguish sessions with the same values of the SenderCompID, TargetCompID and the FIX Protocol version.
storageTypeSession storage type.
storagePluggable Session storage.
~Session ( )

Destructor.

Member Function Documentation

void breakConnection ( )

Terminates the FIX connection in the non-graceful way (without the exchange of Logout (MsgType=5) messages).

Note
This call is thread-safe.
static bool checkWarmupFlags ( int  warmupFlags,
unsigned short  baseListenPort = 5000,
const std::string &  localNetworkInterface = "127.0.0.1" 
)
static

Returns 'true' if given flags work as expected and a real data is not sent to the wire, otherwise - 'false'.

Parameters
warmupFlagsWarmup flags for checking.
baseListenPortBase listen port to use during the checking.
localNetworkInterfaceIP address to bind for listen and outgoing test sockets.
Note
This call is thread-safe.
void clearOutboundQueue ( bool  removeFragmentedPacket = false)

Removes all messages from the outbound queue.

Parameters
removeFragmentedPacket- specifies whether to remove last packet which is partly sent.
Note
This call is thread-safe.
ConnectionMode::Enum connectionMode ( ) const

Returns the connection mode.

void connectionMode ( ConnectionMode::Enum  value)

Sets the connection mode.

void considerRejectOnResendRequestAsGapFill ( bool  consider)

By default if the "Session Level Reject" message is received in replay to the "Resend Request" then this is considered as a serious problem and the FIX connection will be closed.

This property allows to change this behavior and consider the "Session Level Reject" on the "Resend Request" as the "Sequence Reset Gap Fill" message.

bool considerRejectOnResendRequestAsGapFill ( ) const

Returns 'true' if the "Reject" on the "Resend Request" is considered as the "Sequence Reset Gap Fill" message, otherwise - 'false'.

std::string counterpartyHost ( ) const

Returns the counterparty host name.

Note
This call is thread-safe.
std::string counterpartyIpAddress ( ) const

Returns the counterparty address.

Note
This call is thread-safe.
size_t counterpartyPort ( ) const

Returns the counterparty port number.

Note
This call is thread-safe.
Timestamp creationTime ( ) const

Returns the time when logical session was created or last sequence number reset operation was performed.

Originating value is extracted from attached storage using ISessionStorage::sessionCreationTime() method.

Note
This call is thread-safe.
const std::string& customKey ( ) const

Returns Session's Custom Key.

Note
This call is thread-safe.
Dictionary dictionary ( ) const

Instance of the FIX dictionary or standard FIX messages dictionary which is used by the session.

EncryptionMethod::Enum encryptionMethod ( ) const

Returns the current encryption method.

Note
This call is thread-safe.
void encryptionMethod ( EncryptionMethod::Enum  newEncryptionMethod)

Sets the encryption method.

Note
This call is thread-safe.
Message* findSentMessage ( SequenceNumber  messageSequenceNumber)

Returns the sent message if it can be found by the given message sequence number, otherwise - NULL.

Note
This call is thread-safe.
void flushSessionStorage ( )

Flushes all internal buffers of the underlying storage.

Note
This call is thread-safe.
int heartbeatIntervalSec ( ) const

Returns the Heartbeat interval (in seconds).

void ignoreLessThanExpectedSequenceNumber ( bool  ignore)

By default if the incoming message has a sequence number less than expected and the PossDupFlag is not set, it indicates a serious error and leads to FIX connection closing.

This property allows to change this behavior and consider the sequence number of the incoming message, which less than expected, as an expected one.

bool ignoreLessThanExpectedSequenceNumber ( ) const

Returns 'true' if the sequence number of the incoming message, which less than expected, is considered as an expected one, otherwise - 'false'.

InboundMessageLogFilter inboundMessageLogFilter ( ) const

Returns incoming message types to be filtered out from the logs.

Note
This call is thread-safe.
void inboundMessageLogFilter ( const InboundMessageLogFilter filter)

Sets incoming message types to be filtered out from the logs.

Note
This call is thread-safe.
void incomingMessageGapQueueMaximumSize ( size_t  maxSize)

If requestOnlyMissedMessages option is true and the sequence number of an incoming FIX message greater that expected then the resend functionality is run and this incoming message is stored in the incoming message gap queue for further processing.

This property allows to set maximum size of that queue.

size_t incomingMessageGapQueueMaximumSize ( ) const

Returns maximum size of the incoming message gap queue.

By default, the value equal to 1000.

SequenceNumber inSeqNum ( ) const

Returns the expected sequence number of the next incoming message.

Note
This call is thread-safe.
void inSeqNum ( SequenceNumber  seqNum)

Sets the expected sequence number of the next incoming message.

Note
This call is thread-safe.
int listenPort ( ) const

Returns the port to listen on for incoming FIX Connections in Acceptor mode.

Note
This call is thread-safe.
void listenPort ( int  listenPort)

Sets the port to listen on for incoming FIX Connections in Acceptor mode.

Note
This call is thread-safe.
const std::string& localNetworkInterface ( ) const

Returns the local network interface from which you intend to send and receive data.

Note
This call is thread-safe.
void localNetworkInterface ( const std::string &  localNetworkInterface)

Sets the local network interface from which you intend to send and receive data.

Note
This call is thread-safe.
unsigned short localPort ( ) const

Returns the local port from which you intend to send and receive data.

Note
This call is thread-safe.
LocalPortRange localPortRange ( ) const

Returns the local port range, the first available port from this range will be used to send and receive data.

Note
This call is thread-safe.
void localPortRange ( LocalPortRange  portRange)

Sets the local port range, the first available port from this range will be used to send and receive data.

Note
This call is thread-safe.
void logDirectory ( const std::string &  value)

Inbound and outbound messages, session's state data are stored in this directory.

Note
This method can be called only when the session is disconnected.
Exceptions
Exceptionif the session state is not Disconnected.
Note
This call is thread-safe.
const std::string& logDirectory ( ) const

Inbound and outbound messages, session's state data are stored in this directory.

Note
This call is thread-safe.
bool logInboundMessages ( ) const

Returns 'true' if inbound messages are logged, otherwise - 'false'.

By default, the value is true.

void logInboundMessages ( bool  value)

Option to log inbound messages.

void logonAsAcceptor ( )

Establishes the FIX Connection as Acceptor.

Acceptor is the receiving party of the FIX session. It listens for the incoming connection on the pre-defined port. The acceptor has responsibility to perform first level authentication and formally declare the connection request "accepted" through transmission of an acknowledgment Logon message.

Note
This call is thread-safe.
void logonAsInitiator ( const std::string &  host,
int  port,
bool  setResetSeqNumFlag 
)

Establishes FIX Connection as Initiator using the ResetSeqNumFlag (tag 141) field.

Initiator establishes the telecommunications link and initiates the session via transmission of the initial Logon message.

Note
This call is thread-safe.
void logonAsInitiator ( const std::string &  host,
int  port 
)

Establishes FIX Connection as Initiator.

Initiator establishes the telecommunications link and initiates the session via transmission of the initial Logon message.

Note
This call is thread-safe.
void logonAsInitiator ( const std::string &  host,
int  port,
int  heartbeatIntervalSec 
)

Establishes FIX Connection as Initiator using the given Heartbeat interval (seconds).

Note
This call is thread-safe.
void logonAsInitiator ( const std::string &  host,
int  port,
int  heartbeatIntervalSec,
bool  setResetSeqNumFlag,
bool  async = false 
)

Establishes FIX Connection as Initiator using the given Heartbeat interval (seconds) and the ResetSeqNumFlag(141) field.

If the async flag is false then the method is blocked until the acknowledgment Logon message is received. If the async flag is true then the method returns immediately without waiting the acknowledgment Logon message.

Note
This call is thread-safe.
void logonAsInitiator ( const std::string &  host,
int  port,
int  heartbeatIntervalSec,
Message customLogonMsg 
)

Establishes FIX Connection as Initiator using the custom Logon message.

Note
This call is thread-safe.
void logonAsInitiator ( const std::string &  host,
int  port,
int  heartbeatIntervalSec,
Message customLogonMsg,
bool  setResetSeqNumFlag,
bool  async = false 
)

Establishes FIX Connection as Initiator using the custom Logon message and the ResetSeqNumFlag(141) field.

If the async flag is false then the method is blocked until the acknowledgment Logon message is received. If the async flag is true then the method returns immediately without waiting the acknowledgment Logon message.

Note
This call is thread-safe.
void logout ( )

Terminates the FIX Connection.

The initial Logout message is sent to the counterparty and the method is blocked until the acknowledgment Logout message is received.

Note
This call is thread-safe.
void logout ( const std::string &  text,
bool  async = false 
)

Terminates the FIX Connection.

The initial Logout message is sent to the counterparty. If the async flag is false then the method is blocked until the acknowledgment Logout message is received. If the async flag is true then the method returns immediately without waiting the acknowledgment Logout message.

Parameters
textFree format text string that is sent to the counterparty in the Text(58) field of the initial Logout message.
asyncFlag to determine if the synchronous/asynchronous logout is required.
Note
This call is thread-safe.
void logout ( Message customLogoutMessage,
bool  async = false 
)

Terminates the FIX Connection.

The initial Logout message is sent to the counterparty. If the async flag is false then the method is blocked until the acknowledgment Logout message is received. If the async flag is true then the method returns immediately without waiting the acknowledgment Logout message.

Parameters
customLogoutMessageCustom Logout message that is sent to the counterparty.
asyncFlag to determine if the synchronous/asynchronous logout is required.
Note
This call is thread-safe.
void logout ( OnixS::FIX::Core::Messaging::Extras::SerializedMessage *  customLogoutMessage,
bool  async = false 
)
bool logOutboundMessages ( ) const

Returns 'true' if outbound messages are logged, otherwise - 'false'.

By default, the value is true.

void logOutboundMessages ( bool  value)

Option to log outbound messages.

unsigned messageGrouping ( ) const

Returns the number of messages that should be written to the outgoing TCP buffer together.

By default, the corresponding option value of Engine settings is used (0).

void messageGrouping ( unsigned  numberOfMessagesToGroup)

Sets the number of messages that should be written to the outgoing TCP buffer together.

operator const std::string & ( ) const

Returns the text description of this session.

Note
This call is thread-safe.
OutboundMessageLogFilter outboundMessageLogFilter ( ) const

Returns outgoing message types to be filtered out from the logs.

Note
This call is thread-safe.
void outboundMessageLogFilter ( const OutboundMessageLogFilter filter)

Sets outgoing message types to be filtered out from the logs.

Note
This call is thread-safe.
size_t outboundQueueBytes ( ) const

Returns the total number of bytes in the outbound queue.

Note
This call is thread-safe.
SequenceNumber outSeqNum ( ) const

Returns the sequence number of the next outgoing message.

Note
This call is thread-safe.
void outSeqNum ( SequenceNumber  seqNum)

Sets the sequence number of the next outgoing message.

Note
This call is thread-safe.
void preFill ( Message msg) const

Pre-fills session-level fields that are constant during the session's lifetime - SenderCompId, TargetCompId, SenderLocationId, TargetLocationID, SenderSubID, TargetSubID.

Note
This call is thread-safe.
void preFill ( OnixS::FIX::SerializedMessage msg) const

Pre-fills the following fields in the message or messages batch for sending as is:

  • Session-level fields that are constant during the session's lifetime - SenderCompId, TargetCompId, SenderLocationId, TargetLocationI, SenderSubID, TargetSubID.
  • MsgSeqNum field in accordance with the session outgoing sequence number.
  • SendingTime field.
  • BodyLength and CheckSum fields.
Note
This call is thread-safe.
void preFill ( SerializedMessageBatch msgs) const
int reasonableTransmissionTime ( ) const

Returns the reasonable transmission time as % from heartbeatIntervalSec value.

By default, the corresponding option value of Engine settings is used (20%).

void reasonableTransmissionTime ( int  value)

Sets the reasonable transmission time as % from heartbeatIntervalSec value.

When either end of the connection has not received any data for (heartbeatIntervalSec() * (100 + reasonableTransmissionTime())/100) seconds, it will transmit a Test Request message.

If there is still no Heartbeat message received after (heartbeatIntervalSec * (100 + reasonableTransmissionTime())/100) seconds then the connection should be considered lost and corrective action be initiated.

int receiveSpinningTimeout ( ) const

Returns the current receive spinning timeout value (in microseconds).

By default, the value is zero and receive spinning is not used.

void receiveSpinningTimeoutUsec ( int  usec)

Sets the non-blocking receive spinning timeout (in microseconds) before the receiving thread enters into the blocking wait mode.

Note
Should not be greater than 1 sec (minimal heartbeatIntervalSec()).
const OnixS::Threading::CpuIndexes& receivingThreadAffinity ( ) const

Returns the CPU affinity of the receiving thread.

void receivingThreadAffinity ( const OnixS::Threading::CpuIndexes cpuIndexes)

Sets the CPU affinity of the receiving thread.

void receivingThreadAffinity ( const OnixS::Threading::CpuIndex  cpuIndex)

Sets the CPU affinity of the receiving thread to a CPU.

int receivingThreadPolicy ( ) const

Returns the scheduling policy of the receiving thread.

void receivingThreadPolicy ( int  policy)

Sets the scheduling policy of the receiving thread.

int receivingThreadPriority ( ) const

Returns the priority of the receiving thread.

void receivingThreadPriority ( int  priority)

Sets the priority of the receiving thread.

void reconnectAttempts ( int  value)

Sets the number of attempts to restore the telecommunication link.

int reconnectAttempts ( ) const

Returns the number of attempts to restore the telecommunication link.

By default, the corresponding option value of Engine settings is used (3).

void reconnectInterval ( int  value)

Sets the time interval between the attempts to restore the telecommunication link (in seconds).

int reconnectInterval ( ) const

Returns the time interval between the attempts to restore the telecommunication link (in seconds).

By default, the corresponding option value of Engine settings is used (180).

void registerListener ( ISessionListener listener)

Registers the Session listener.

Exceptions
Exceptionif the listener is already registered.
void reportNewMessagesWhileWaitingForMissedMessages ( bool  report)

When the message gap is detected the "Resend Request" FIX Message is sent and Session state is changed to "AwaitReplyOnResendRequest".

By default in this state the incoming new messages (without the PossDupFlag (tag #43) flag) are ignored because we expect them to be re-sent later again with the PossDupFlag flag.

This property allows to change this behavior and report the new messages anyway.

Note
In this mode messages could be reported out of the original order: e.g. MsgSeqNum could be: 3 (original), 4 (original), 2 (PossDupFlag='Y'), 3 (PossDupFlag='Y'), 4 (PossDupFlag='Y') and some messages could be received two times: first time without PossDupFlag='Y' and second time - with this flag.
bool reportNewMessagesWhileWaitingForMissedMessages ( ) const

Returns 'true' if the new messages are reported even when the message gap is detected and the reply on the "Resend Request" message is expected, otherwise - 'false'.

void requestOnlyMissedMessages ( bool  request)

By default the "Resend Request" message requests all messages begin from the first missed one.

This property allows to change this behavior and request only missed messages.

Note
This method can be called only when the session is disconnected.
bool requestOnlyMissedMessages ( ) const

Returns 'true' if the "Resend Request" message requests only missed messages, otherwise - 'false'.

void resendingQueueSize ( int  value)

Sets the number of sent messages that are available for resending on counterpart's Resend Request <2> message.

Note
This call is thread-safe.
int resendingQueueSize ( ) const

Returns the number of sent messages that are available for resending on counterpart's Resend Request <2> message.

By default, the corresponding option value of Engine settings is used (1000).

Note
This call is thread-safe.
void resendRequestMaximumRange ( int  range)

Sets the maximum number of messages to be requested in one Resend Request (MsgType=2) message.

See also
Session::ResendRequestMaximumRangeNoLimit.
Parameters
rangeMaximum number of messages to be requested in one Resend Request (MsgType=2) message. Cannot be negative.
Note
This call is thread-safe.
int resendRequestMaximumRange ( ) const

Returns the maximum number of messages to be requested in one Resend Request (MsgType=2) message.

By default, the value is zero (no limit).

See also
Session::ResendRequestMaximumRangeNoLimit.
Note
This call is thread-safe.
void resetLocalSequenceNumbers ( )

Backups the current log files and resets the local sequence numbers to 1.

Note
This method can be called only when the session is disconnected.
This call is thread-safe.
void resetLocalSequenceNumbersOnLogon ( bool  reset)

Option to automatically reset the local sequence numbers to 1 during every logon.

bool resetLocalSequenceNumbersOnLogon ( ) const

Returns 'true' if local sequence numbers are reset automatically to 1 during every logon, otherwise - 'false'.

void resetSeqNumViaLogonExchange ( )

Sends a Logon message with the ResetSeqNumFlag set.

Note
This call is thread-safe.
SessionRole::Enum role ( ) const

Returns the session role.

Note
This call is thread-safe.
void send ( Message msg)

Sends the message to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Note
This call is asynchronous.
This call is thread-safe.
void send ( OnixS::FIX::SerializedMessage msg)
void send ( OnixS::FIX::SerializedMessage msg,
SessionSendMode::Enum  mode 
)

Performs sending via a specific API (e.g.

zero-copy send) of the message to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Note
This call is asynchronous.
This call is thread-safe.
void send ( const MessageBatch msgs)

Sends messages in a batch to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Note
This call is asynchronous.
This call is thread-safe.
void send ( const SerializedMessageBatch msgs)
void sendAsIs ( OnixS::FIX::SerializedMessage msg)

Sends serialized message(s) to the counterparty without any fields updating.

One can use the preFill method to prepare message(s) for sending.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Note
This call is asynchronous.
This call is thread-safe.
void sendAsIs ( const SerializedMessageBatch msgs)
const std::string& senderCompId ( ) const

Returns the assigned value used to identify firm sending message (the SenderCompID (tag 49) field value in outgoing messages).

Note
This call is thread-safe.
std::string senderLocationId ( ) const

Returns the SenderLocationID (tag 142) field values for all outgoing messages.

Note
This call is thread-safe.
void senderLocationId ( const std::string &  value)

Sets the SenderLocationID (tag 142) field values for all outgoing messages.

Note
This call is thread-safe.
std::string senderSubId ( ) const

Returns the SenderSubID (tag 50) field values for all outgoing messages.

Note
This call is thread-safe.
void senderSubId ( const std::string &  value)

Sets the SenderSubID (tag 50) field values for all outgoing messages.

Note
This call is thread-safe.
const OnixS::Threading::CpuIndexes& sendingThreadAffinity ( ) const

Returns the CPU affinity of the sending thread.

void sendingThreadAffinity ( const OnixS::Threading::CpuIndexes cpuIndexes)

Sets the CPU affinity index of the sending thread.

void sendingThreadAffinity ( const OnixS::Threading::CpuIndex  cpuIndex)

Sets the CPU affinity index of the sending thread a CPU.

int sendingThreadPolicy ( ) const

Returns the scheduling policy of the sending thread.

void sendingThreadPolicy ( int  policy)

Sets the scheduling policy of the sending thread.

int sendingThreadPriority ( ) const

Returns the priority of the sending thread.

void sendingThreadPriority ( int  priority)

Sets the priority of the sending thread.

void sendingTimeFormat ( TimestampFormat::Enum  format)

Sets the time format of SendingTime of every sent message.

By default, the YYYYMMDDHHMMSSMsec format is used.

bool sendLogoutOnException ( ) const

Returns option which controls whether to send the logout message before dropping the telecommunication link, in case of exception.

By default, the corresponding option value of Engine settings is used (false).

void sendLogoutOnException ( bool  sendLogoutOnException)

Sets value of option which controls whether to send the logout message before dropping the telecommunication link, in case of exception.

void sendReject ( SequenceNumber  refSeqNumber,
const std::string &  text 
)

Sends the Reject (MsgType 3) message.

Parameters
refSeqNumberMsgSeqNum of rejected message.
textMessage to explain the reason for rejection.
Note
This call is thread-safe.
void sendResendRequest ( SequenceNumber  beginSeqNumber)

Sends the Resend Request (MsgType 2) message.

Note
Normally, "Resend Request" message is sent automatically. This method allows to simulate a sequence gap by sending this message manually. This can be needed in some venue specific cases. This method should not be used in the normal work.
Parameters
beginSeqNumberBegin sequence number of the first requested message in the range.
Note
This call is thread-safe.
void sendResendRequestOnEachMessageGap ( bool  send)

By default the "Resend Request" message is sent only once - when the first gap is detected.

This property allows to change this behavior and send the "Resend Request" message on each detected message sequence number gap.

bool sendResendRequestOnEachMessageGap ( ) const

Returns 'true' if the "Resend Request" message is sent on each detected message sequence number gap, otherwise - 'false'.

int sendSpinningTimeout ( ) const

Returns the current send spinning timeout value (in microseconds).

By default, the value is zero and send spinning is not used.

void sendSpinningTimeoutUsec ( int  usec)

Sets the send spinning timeout (in microseconds) of the Session::send(..) method to wait for the socket sending buffer availability in the spin loop mode before placing the message to the outgoing queue (to be sent later by the sending thread).

Note
Should not be greater than 1 sec (minimal heartbeatIntervalSec()).
void sendTestRequest ( const std::string &  testReqId = "")

Sends the Test Request (MsgType 1) message.

Note
This call is thread-safe.
void shutdown ( )

Shutdowns the session.

Note
This call is thread-safe.
OnixS::Sockets::Handle socketHandle ( )

Returns the socket handle which the session uses to transmit FIX data.

Note
This call is thread-safe.
void socketOptions ( const OnixS::Sockets::SocketOptions &  options)

Additional options, which should be set to the session socket when it is created.

For initiator sessions, options are set before socket connect(..) call. For acceptor sessions, options are set after socket accept(..) call.

bool specifyLastMsgSeqNumProcessed ( ) const

Returns 'true' if the LastMsgSeqNumProcessed (tag 369) field is specified on every message sent, otherwise - 'false'.

By default, the option value is false.

void specifyLastMsgSeqNumProcessed ( bool  specify)

Option to specify the LastMsgSeqNumProcessed (tag 369) field on every message sent.

Useful for detecting a backlog with a counterparty.

Note
Option does not affect the SerializedMessage send.
void sslCaFile ( const std::string &  value)

Sets the path to the trusted certification authority certificate file in (Privacy Enhanced Mail) Base64 encoded (.pem) format.

Note
This call is thread-safe.
std::string sslCaFile ( ) const

Returns the path to trusted certification authority certificate file in (Privacy Enhanced Mail) Base64 encoded (.pem) format.

Note
This call is thread-safe.
std::string sslCertificateFile ( ) const

Returns the SSL certificate file.

Note
This call is thread-safe.
void sslCertificateFile ( const std::string &  file)

Sets the SSL certificate file.

Note
Only the (Privacy Enhanced Mail) Base 64 Encoded (.pem) SSL certificates are supported.
This call is thread-safe.
std::string sslPrivateKeyFile ( ) const

Returns the SSL private key file.

Note
This call is thread-safe.
void sslPrivateKeyFile ( const std::string &  file)

Sets the SSL private key file.

Note
Only the (Privacy Enhanced Mail) Base 64 Encoded (.pem) SSL certificates are supported.
This call is thread-safe.
std::string sslPrivateKeyPassword ( ) const

Returns the SSL private key file password.

Note
This call is thread-safe.
void sslPrivateKeyPassword ( const std::string &  password)

Sets the SSL private key file password.

Note
This call is thread-safe.
void sslVerifyPeer ( bool  verify)

Set option to request peer certificates and perform the certificate verification.

Note
This call is thread-safe.
bool sslVerifyPeer ( ) const

Returns option to request peer certificates and perform the certificate verification.

By default, the corresponding option value of Engine settings is used (false).

Note
This call is thread-safe.
SessionState::Enum state ( ) const

Returns Session's state.

Note
This call is thread-safe.
const std::string& storageId ( ) const

Returns the underlying storage Id.

Note
This call is thread-safe.
void supportNextExpectedMsgSeqNum ( bool  support)

Sets NextExpectedMsgSeqNum field (tag 789) support in Logon messages.

bool supportNextExpectedMsgSeqNum ( ) const

Returns 'true' if NextExpectedMsgSeqNum field (tag 789) is supported in Logon messages, otherwise - 'false'.

By default, the option value is false.

const std::string& targetCompId ( ) const

Returns the Assigned value used to identify receiving firm (the TargetCompID (tag 56) field value in outgoing messages).

Note
This call is thread-safe.
std::string targetLocationId ( ) const

Returns the TargetLocationID (tag 143) field values for all outgoing messages.

Note
This call is thread-safe.
void targetLocationId ( const std::string &  value)

Sets the TargetLocationID (tag 143) field values for all outgoing messages.

Note
This call is thread-safe.
std::string targetSubId ( ) const

Returns the TargetSubID (tag 57) field values for all outgoing messages.

Note
This call is thread-safe.
void targetSubId ( const std::string &  value)

Sets the TargetSubID (tag 57) field values for all outgoing messages.

Note
This call is thread-safe.
bool tcpNoDelayOption ( ) const

Returns option to improve latency at the expense of message throughput (TCP_NODELAY socket option).

By default, the corresponding option value of Engine settings is used (true).

void tcpNoDelayOption ( bool  improveLatency = true)

Sets value of option to improve latency at the expense of message throughput (TCP_NODELAY socket option).

std::string threadNameSuffix ( ) const

Returns the thread name suffix for receiving (R:threadNameSuffix) and sending (S:threadNameSuffix) threads.

Note
This call is thread-safe.
void threadNameSuffix ( const std::string &  value)

Sets the thread name suffix for receiving ("R:threadNameSuffix") and sending ("S:threadNameSuffix") threads.

If threadNameSuffix is not specified, it is set by default to ("R:senderCompId-targetCompId")("S:senderCompId-targetCompId").

Note
This method can be called only when the session is disconnected.
Exceptions
Exceptionif the session state is not Disconnected.
Note
This call is thread-safe.
void throttle ( )

Performs throttling of a session that must be called before each of a send function call.

If the count of messages per a time unit exceeds a throttling limit, the function will be blocked until the given time interval is passed.

Note
This call is thread-safe.
void throttlingLimit ( size_t  messagesCount,
size_t  intervalInMs = 1000 
)

Sets throttling limit parameters.

Parameters
messagesCountMessage limit per a time unit.
intervalInMsTime interval to limit messages.
Note
This call is thread-safe.
std::string toString ( ) const

Returns the session string presentation.

Note
This call is thread-safe.
void unregisterAllListeners ( )

Un-registers all Session listener.

void unregisterListener ( ISessionListener listener)

Un-registers the Session listener.

bool updateSendingTimeField ( ) const

Returns 'true' if updating of SendingTime is turn on for every message, otherwise - 'false'.

By default, the option value is true.

void updateSendingTimeField ( bool  specify)

Option to specify updating of SendingTime of every sent message.

bool validateDuplicatedField ( ) const

Returns option which controls duplicated field validation.

By default, the corresponding option value of Engine settings is used (false).

void validateDuplicatedField ( bool  value)

Sets value of option which controls duplicated field validation.

bool validateEmptyFieldValues ( ) const

Returns option to validate the empty field values of FIX messages in accordance with the FIX protocol or its FIX Dictionary.

By default, the corresponding option value of Engine settings is used (false).

void validateEmptyFieldValues ( bool  )

Sets option to validate the empty field values of FIX messages in accordance with the FIX protocol or its FIX Dictionary.

bool validateFieldValues ( ) const

Returns option to validate the field values of FIX messages in accordance with the FIX protocol or its FIX Dictionary.

By default, the corresponding option value of Engine settings is used (false).

void validateFieldValues ( bool  )

Sets option to validate the field values of FIX messages in accordance with the FIX protocol or its FIX Dictionary.

bool validateRepeatingGroupEntryCount ( ) const

Returns option which controls repeating group entry count validation.

By default, the corresponding option value of Engine settings is used (true).

void validateRepeatingGroupEntryCount ( bool  value)

Sets value of option which controls repeating group entry count validation.

bool validateRepeatingGroupLeadingTag ( ) const

Returns option which controls repeating group leading tag validation.

By default, the corresponding option value of Engine settings is used (false).

void validateRepeatingGroupLeadingTag ( bool  value)

Sets value of option which controls repeating group leading tag validation.

bool validateRequiredFields ( ) const

Returns option to validate the presence of required fields in inbound and outbound messages.

By default, the corresponding option value of Engine settings is used (false).

void validateRequiredFields ( bool  )

Sets option to validate the presence of required fields in inbound and outbound messages.

void validateSequenceNumbers ( bool  value)

Options to turn on/off incoming message sequence numbers validation.

bool validateSequenceNumbers ( ) const

Returns the current status of incoming message sequence numbers validation.

By default the option value is true.

bool validateUnknownFields ( ) const

Returns option to validate the presence of unknown fields.

By default, the corresponding option value of Engine settings is used (false).

void validateUnknownFields ( bool  )

Sets option to validate the presence of unknown fields.

bool validateUnknownMessages ( ) const

Returns option to validate the presence of unknown FIX messages.

By default, the corresponding option value of Engine settings is used (false).

void validateUnknownMessages ( bool  )

Sets option to validate the presence of unknown FIX messages.

void warmUp ( OnixS::FIX::SerializedMessage msg,
int  warmupFlags = 0 
)

This method warms up the sending path.

Parameters
msgMessage to warm up the assembly part of the sending path.
warmupFlagsSpecific flags which can be used to turn on the warmup feature for a specific NIC.
Note
This call is thread-safe.

Friends And Related Function Documentation

friend class Engine::Impl
friend

Definition at line 1363 of file Session.h.

Member Data Documentation

const OnixS::Sockets::Handle InvalidSocketHandle
static

Represents invalid value of socket handle.

Definition at line 1315 of file Session.h.

const unsigned int ResendRequestMaximumRangeNoLimit
static

Represents unlimited number of messages to be requested in one Resend Request (MsgType=2) message.

Default value is 0.

Definition at line 884 of file Session.h.

const int UndefinedPriorityAndPolicy
static

Represents undefined value of priority and policy.

Definition at line 1012 of file Session.h.


The documentation for this class was generated from the following file: