B2BITS FIX Antenna C++ 2.33.0
|
FIX Session. More...
#include <B2BITS_Session.h>
Public Types | |
enum | ActiveConnection { PRIMARY_CONNECTION = 0 , BACKUP_CONNECTION , RESTORE_CONNECTION } |
Active connection to use. More... | |
typedef SessionRole | Role |
Session role. | |
enum | SeqNumResetStrategy { RESET_SEQNUM_STRATEGY , RESET_SEQNUM_AND_SEND_LOGON_STRATEGY } |
Sequence numbers reset strategy. More... | |
enum | State { ESTABLISHED , INITIAL , NON_GRACEFULLY_TERMINATED , RECONNECT , CORRECTLY_TERMINATED , WAIT_FOR_CONFIRM_LOGON , WAIT_FOR_CONFIRM_LOGOUT , WAIT_FOR_FIRST_LOGON , SWITCH_CONNECTION , WAIT_FOR_FIRST_HELLO , WAIT_FOR_CONFIRM_HELLO , WAIT_FOR_CONNECT } |
Possible states of Session. More... | |
Public Member Functions | |
virtual void | attachStateObserver (SessionStateObserver *observer)=0 |
Attaches session state observer. | |
virtual void | closeMessageStorage ()=0 |
Close message storage. | |
virtual void | connect (const FixT11TcpParameters &protocolConfig, const FixT11TcpBackupParameters *backupConn=NULL, ActiveConnection activeConn=PRIMARY_CONNECTION)=0 |
Establishes the FIX session over FIXT11_TCP underlying protocol. | |
virtual void | connect (const FixTcpParameters &protocolConfig, const FixTcpBackupParameters *backupConn=NULL, ActiveConnection activeConn=PRIMARY_CONNECTION)=0 |
Establishes the FIX session over FIX_TCP underlying protocol. | |
virtual void | connect (int HBI, const FIXMessage &customLogonMsg, const std::string &host, int port, const SessionBackupParameters *backupConn=NULL, ActiveConnection activeConn=PRIMARY_CONNECTION)=0 |
Establishes the FIX session as Initiator using the custom Logon message. | |
virtual void | connect (int HBI, const std::string &host, int port, const SessionBackupParameters *backupConn=NULL, ActiveConnection activeConn=PRIMARY_CONNECTION)=0 |
Establishes the FIX session as Initiator. | |
virtual void | connect (SessionRole sessionRole=NA_SESSION_ROLE, const SessionBackupParameters *pSessionBackupParameters=NULL)=0 |
Establishes the FIX session. | |
virtual void | detachStateObserver ()=0 |
Detaches session state observer. | |
virtual void | disconnect (bool forcefullyMarkAsTerminated=false)=0 |
Initiates disconnect of the session. | |
virtual void | disconnect (const std::string &logoutText, bool forcefullyMarkAsTerminated=false)=0 |
Initiates disconnect of the session with the given logout text. | |
virtual void | disconnectNonGracefully ()=0 |
Closes the telecommunication link and switches the session into the NON_GRACEFULLY_TERMINATED state. | |
virtual void | disconnectSync (bool forcefullyMarkAsTerminated=false) |
Initiates synchronous disconnect of the session. | |
virtual void | disconnectSync (const std::string &logoutText, bool forcefullyMarkAsTerminated=false) |
Initiates synchronous disconnect of the session with the given logout text. | |
virtual ActiveConnection | getActiveConnectionType () const =0 |
Returns current connection type. | |
virtual SessionExtraParameters | getActiveParameters () const =0 |
Returns std::string representation of active session parameters. | |
virtual FIXVersion | getAppBaseVer () const =0 |
Returns the FIX application protocol base version. | |
virtual ProtocolIndex | getAppVer () const =0 |
Returns the FIX application protocol index in the parser. | |
virtual std::unique_ptr< SessionBackupParameters > | getBackupParameters () const =0 |
Returns std::string representation of backup session parameters. | |
virtual unsigned char | getCurrentTagsDelimiter () const =0 |
Returns session's tags delimiter that is currently being used;. | |
virtual Engine::EncryptMethod | getEncryptionMethod () const =0 |
Returns the encryption method. | |
virtual int | getHBI () const =0 |
Returns Heartbeat interval (HeartBtInt) in seconds. | |
virtual const std::string * | getId () const =0 |
Returns the session's ID in the format 'SenderCompID 0x01 TargetCompId' or . | |
virtual int | getInSeqNum () const =0 |
Returns the next expected incoming sequence numbers for this FIX session. | |
virtual std::unique_ptr< InternalState > | getInternalState () const =0 |
Returns current internal state for this FIX session. | |
virtual const std::string | getMsgStorageBaseFilePath () const =0 |
Returns message storage base file path. | |
virtual int | getOutSeqNum () const =0 |
Returns the outgoing sequence numbers for this FIX session (MsgSeqNum of the next outgoing message). | |
virtual int | getOutSeqNumNoLock () const =0 |
Returns the outgoing sequence numbers for this FIX session (MsgSeqNum of the next outgoing message). | |
virtual SessionExtraParameters | getPrimaryParameters () const =0 |
Returns std::string representation of primary session parameters. | |
virtual void | getReceivedMessages (std::vector< FIXMessage * > *pMessages, const MsgFilter &msgFilter) const =0 |
Retrieves messages received by the session. | |
virtual System::InetAddress | getRemoteAddress () const =0 |
Returns the remote FIX Engine's IP Address. | |
virtual const std::string * | getRemoteHost () const =0 |
Returns the remote FIX Engine's host name. | |
virtual System::IPAddr | getRemoteHostIP () const |
Returns the remote FIX Engine's IP Address. | |
virtual int | getRemotePort () const =0 |
Returns the remote FIX Engine's port number. | |
virtual Role | getRole () const =0 |
Returns session's role. | |
virtual const std::string * | getSender () const =0 |
Returns SenderCompID. | |
virtual SessionEx * | getSessionEx () |
Extends session interface. | |
virtual const SessionId & | getSessionId () const =0 |
Returns reference to SessionId. | |
virtual State | getState () const =0 |
Returns session's state;. | |
virtual const char * | getStateAsString () const =0 |
Returns current session's state as std::string;. | |
virtual void | getStatistics (FixSessionStatisticsLite &statistics) const =0 |
Returns Session's Lite statistics. | |
virtual System::u64 | getStorageCreationTime () const =0 |
Returns storage creation time as number of milliseconds since 1970.01.01 If no storage is assigned with Session, method returns 0. | |
virtual MessageStorageType | getStorageType () const =0 |
Returns a session storage type. | |
virtual const std::string * | getTarget () const =0 |
Returns TargetCompID. | |
virtual UnderlyingProtocol | getUnderlyingProtocol () const =0 |
Returns type of the underlying protocol. | |
virtual FIXVersion | getVer () const =0 |
Returns the FIX protocol version. | |
virtual void | inflate (FIXMessage *pMsg, int msgSeqNumSize, PutMessageOptions const *options=NULL) const =0 |
Sets static session level fields in the message and reserves space for volatile session level fields. | |
virtual bool | isInEstablishingConnectionMode () const =0 |
Returns true if the session is in establishing connection mode (INITIAL, RECONNECT, WAIT_FOR_CONFIRM_LOGON, WAIT_FOR_FIRST_LOGON, or WAIT_FOR_CONNECT states) | |
virtual bool | isTCPBuffer () const =0 |
virtual FIXMessage * | locateSentMessage (int seqNum) const =0 |
Searches for a message by sequence number in the outgoing storage. | |
virtual void | lock ()=0 |
Locks session's mutex. | |
virtual FIXMessage * | newSkel (const char *msgType, Engine::ProtocolIndex app_ver=Engine::NA) const =0 |
Creates instance of the FIX message. | |
virtual std::size_t | outgoingQueueSize () const =0 |
Returns size of the outgoing message queue. | |
virtual FIXMessage * | parse (std::string const &raw) const =0 |
Creates instance of the FIX message. | |
virtual ParserID | parserID () const =0 |
Returns unique parser identifier of the session. | |
virtual void | ping (const std::string &testReqID="")=0 |
Sends Test Request message. | |
ParserID | protocolID () const |
Returns unique parser identifier of the session. | |
virtual void | put (const std::list< PreparedMessage * > &lMsgs) |
Sends the list of given messages to the remote FIX engine in one packet. | |
virtual void | put (const std::string &msgHeader, const std::string &msgBody)=0 |
Sends the given message to the remote FIX engine. | |
virtual void | put (FIXMessage *pMsg, PutMessageOptions const *options=NULL)=0 |
Sends the given message to the remote FIX engine. | |
virtual void | put (PreparedMessage *pMsg)=0 |
Sends the given message to the remote FIX engine. | |
virtual void | putAsIs (FIXMessage *msg, int seqNum, bool updateOutSeqNum)=0 |
Stores given message to outgoing storage and sends to socket. | |
virtual void | putAsIs (PreparedMessage *msg, int seqNum, bool updateOutSeqNum)=0 |
Stores given message to outgoing storage and sends to socket. | |
virtual void | putAsIsNoLock (FIXMessage *msg, int seqNum, bool updateOutSeqNum)=0 |
Stores given message to outgoing storage and sends to socket. | |
virtual void | putAsIsNoLock (PreparedMessage *msg, int seqNum, bool updateOutSeqNum)=0 |
Stores given message to outgoing storage and sends to socket. | |
virtual Application * | registerApplication (Application *pNewApplication, unsigned int delay=300, int maxTries=-1)=0 |
Registers Application. | |
virtual void | resetMessageStorage ()=0 |
Reset messages storage, so nothing will be send on ResendRequest. | |
virtual void | resetSeqNum (SeqNumResetStrategy strategy=RESET_SEQNUM_AND_SEND_LOGON_STRATEGY)=0 |
Resets sequence numbers according to chosen strategy. | |
virtual void | setEnableMessageRejecting (bool enable)=0 |
Forcedly sets the value of the Enable Message Rejecting. | |
virtual void | setForcedReconnect (bool enable)=0 |
Forcedly sets the value of the Forced Reconnect. | |
virtual void | setInSeqNum (int seqNum)=0 |
Forcedly sets the value of the incoming sequence number (the expected MsgSeqNum of the next incoming message). | |
virtual void | setInternalState (InternalState *state)=0 |
Forcedly sets the internal state. | |
virtual void | setIntradayLogoutToleranceMode (bool enable)=0 |
Forcedly sets the value of the Intraday Logout Tolerance Mode. | |
virtual void | setOutSeqNum (int seqNum)=0 |
Forcedly sets the value of the outgoing sequence number (MsgSeqNum of the next outgoing message). | |
virtual void | setOutSeqNumNoLock (int seqNum)=0 |
Sets the value of the outgoing sequence number (MsgSeqNum of the next outgoing message). | |
virtual void | setSenderLocationID (const std::string &id)=0 |
Forcedly sets the value of the Sender Location ID. | |
virtual void | setSenderSubID (const std::string &id)=0 |
Forcedly sets the value of the Sender Sub ID. | |
virtual void | setSessionDestructionEvent (System::ReferenceableManualEvent *event) throw () =0 |
Assigns Session with Event object to notify user about session destruction. | |
virtual void | setTargetLocationID (const std::string &id)=0 |
Forcedly sets the value of the Target Location ID. | |
virtual void | setTargetSubID (const std::string &id)=0 |
Forcedly sets the value of the Target Sub ID. | |
virtual bool | setTCPBuffer (bool enable)=0 |
Enables or disables TCP buffer. | |
virtual void | switchConnection ()=0 |
Switch session to the another connection. | |
virtual void | unlock ()=0 |
UnLocks session. | |
virtual bool | waitForStates (const std::set< State > &states, const std::chrono::milliseconds &timeout=(std::chrono::milliseconds::max)()) const =0 |
Waits before session gets into any state among provided. | |
virtual void | waitForTerminated () throw () =0 |
Blocks execution until all threads accittiated with Session are stopped. | |
Public Member Functions inherited from Utils::ReferenceCounter | |
virtual bool | addRef () const throw () |
Increments reference counter. | |
virtual long | getNRef () const throw () |
Returns the current value of the reference counter. | |
ReferenceCounter () throw () | |
Constructor. | |
virtual long | release () const throw () |
Decrements reference counter. | |
Static Public Member Functions | |
static const char * | connState2string (ActiveConnection aState) |
Returns the std::string representation of the given connection state value. | |
static const char * | messageStorageTypeToString (MessageStorageType const &value) |
Converts MessageStorageType to string. | |
static const char * | role2string (SessionRole role) |
Returns the string representation of the given Role value. | |
static const char * | state2string (State state) |
Returns the string representation of the given state value. | |
static MessageStorageType | stringToMessageStorageType (char const *value) |
Converts string to MessageStorageType. | |
static MessageStorageType | stringToMessageStorageTypeCaseI (char const *value) |
Converts string to MessageStorageType. | |
Protected Member Functions | |
Session () | |
Constructor. | |
virtual | ~Session () |
Destructor. | |
Protected Member Functions inherited from Utils::ReferenceCounter | |
long | decrement () const throw () |
Decrements counter and returns new counter value. | |
long | increment () const throw () |
Increments counter and returns new counter value. | |
virtual | ~ReferenceCounter () |
Destructor. | |
FIX Session.
Provides interface to establish connection, send and receive messages. Instance of the session can be created by Engine::FixEngine class.
Example:
typedef SessionRole Engine::Session::Role |
Session role.
Sequence numbers reset strategy.
Possible states of Session.
|
inlineprotected |
Constructor.
|
inlineprotectedvirtual |
Destructor.
|
pure virtual |
Attaches session state observer.
|
pure virtual |
Close message storage.
Method forcedly closes storage if session is in the NGT/CT state.
|
pure virtual |
Establishes the FIX session over FIXT11_TCP underlying protocol.
protocolConfig | - set of the FIXT11_TCP protocol parameters. |
backupConn | - parameters of the backup connection |
activeConn | - specifies which connection will be used, by default primary connection |
|
pure virtual |
Establishes the FIX session over FIX_TCP underlying protocol.
protocolConfig | - set of the FIX_TCP protocol parameters. |
backupConn | - parameters of the backup connection |
activeConn | - specifies which connection will be used, by default primary connection |
|
pure virtual |
Establishes the FIX session as Initiator using the custom Logon message.
HBI | Heartbeat interval (in seconds) |
customLogonMsg | the custom Logon message. |
host | remote FIX engine's host name or address. |
port | remote FIX engine's port. |
encryption | Encrypt method. |
backupConn | - parameters of the backup connection |
activeConn | - specifies which connection will be used, by default primary connection |
|
pure virtual |
Establishes the FIX session as Initiator.
HBI | Heartbeat interval (seconds) |
host | remote FIX engine's host name or address. |
port | remote FIX engine's port. |
encryption | Encrypt method. |
backupConn | - parameters of the backup connection |
activeConn | - specifies which connection will be used, by default primary connection |
|
pure virtual |
Establishes the FIX session.
sessionRole | - session role to connect as. Default - NA_SESSION_ROLE means no role override use pre-configured via session extra parameters or engine.properties role. |
pSessionBackupParameters | - session backup parameters. It is applicable to initiator sessions only,. |
|
static |
Returns the std::string representation of the given connection state value.
|
pure virtual |
Detaches session state observer.
|
pure virtual |
Initiates disconnect of the session.
forcefullyMarkAsTerminated | if true then the session will be marked as correctly terminated and persistent information about it will not be used during the subsequent connections. |
|
pure virtual |
Initiates disconnect of the session with the given logout text.
forcefullyMarkAsTerminated | if true then the session will be marked as correctly terminated and persistent information about it will not be used during the subsequent connections. |
logoutText | Reason of disconnecting |
|
pure virtual |
Closes the telecommunication link and switches the session into the NON_GRACEFULLY_TERMINATED state.
|
virtual |
Initiates synchronous disconnect of the session.
forcefullyMarkAsTerminated | if true then the session will be marked as correctly terminated and persistant information about it will not be used during the subsequent connections. |
|
virtual |
Initiates synchronous disconnect of the session with the given logout text.
forcefullyMarkAsTerminated | if true then the session will be marked as correctly terminated and persistant |
logoutText | Reason of disconnecting information about it will not be used during the subsequent connections. |
|
pure virtual |
Returns current connection type.
|
pure virtual |
Returns std::string representation of active session parameters.
|
pure virtual |
Returns the FIX application protocol base version.
|
pure virtual |
Returns the FIX application protocol index in the parser.
|
pure virtual |
Returns std::string representation of backup session parameters.
|
pure virtual |
Returns session's tags delimiter that is currently being used;.
|
pure virtual |
Returns the encryption method.
|
pure virtual |
Returns Heartbeat interval (HeartBtInt) in seconds.
|
pure virtual |
Returns the session's ID in the format 'SenderCompID 0x01 TargetCompId' or .
in format 'SenderCompID 0x01 TargetCompId 0x01 qualifier' if session qualifier is available.
|
pure virtual |
Returns the next expected incoming sequence numbers for this FIX session.
|
pure virtual |
Returns current internal state for this FIX session.
|
pure virtual |
Returns message storage base file path.
Base file path is path to the file set without extension.
|
pure virtual |
Returns the outgoing sequence numbers for this FIX session (MsgSeqNum of the next outgoing message).
|
pure virtual |
Returns the outgoing sequence numbers for this FIX session (MsgSeqNum of the next outgoing message).
|
pure virtual |
Returns std::string representation of primary session parameters.
|
pure virtual |
Retrieves messages received by the session.
pMessages | List of messages. |
msgFilter | specifies selection criteria. |
|
pure virtual |
Returns the remote FIX Engine's IP Address.
Utils::Exception | if no data is available |
|
pure virtual |
Returns the remote FIX Engine's host name.
Utils::Exception | if no data is available |
|
virtual |
Returns the remote FIX Engine's IP Address.
Utils::Exception | if no data is available |
|
pure virtual |
Returns the remote FIX Engine's port number.
|
pure virtual |
Returns session's role.
|
pure virtual |
Returns SenderCompID.
|
virtual |
Extends session interface.
|
pure virtual |
Returns reference to SessionId.
|
pure virtual |
Returns session's state;.
|
pure virtual |
Returns current session's state as std::string;.
|
pure virtual |
Returns Session's Lite statistics.
|
pure virtual |
Returns storage creation time as number of milliseconds since 1970.01.01 If no storage is assigned with Session, method returns 0.
|
pure virtual |
Returns a session storage type.
|
pure virtual |
Returns TargetCompID.
|
pure virtual |
Returns type of the underlying protocol.
|
pure virtual |
Returns the FIX protocol version.
|
pure virtual |
Sets static session level fields in the message and reserves space for volatile session level fields.
[out] | pMsg | Pointer to the FIXMessage to store field values |
[in] | msgSeqNumSize | Number of characters for MsgSeqNum field to reserve. |
[in] | options | Extra parameters. |
|
pure virtual |
Returns true if the session is in establishing connection mode (INITIAL, RECONNECT, WAIT_FOR_CONFIRM_LOGON, WAIT_FOR_FIRST_LOGON, or WAIT_FOR_CONNECT states)
|
pure virtual |
|
pure virtual |
Searches for a message by sequence number in the outgoing storage.
|
pure virtual |
Locks session's mutex.
|
static |
Converts MessageStorageType to string.
|
pure virtual |
Creates instance of the FIX message.
|
pure virtual |
Returns size of the outgoing message queue.
|
pure virtual |
Creates instance of the FIX message.
|
pure virtual |
Returns unique parser identifier of the session.
|
pure virtual |
Sends Test Request message.
testReqID | The TestReqID field (tag = 112) - Identifier included in Test Request message to be returned in resulting Heartbeat message. If empty then a timestamp std::string will be used as the value. |
ParserID Engine::Session::protocolID | ( | ) | const |
Returns unique parser identifier of the session.
|
inlinevirtual |
Sends the list of given messages to the remote FIX engine in one packet.
After Session::put is return, message can be destroyed by user.
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Sends the given message to the remote FIX engine.
msgHeader | the message header in the native FIX format. |
msgBody | the message body in the native FIX format. |
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Sends the given message to the remote FIX engine.
After Session::put is return, message can be destroyed by user.
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Sends the given message to the remote FIX engine.
After Session::put is return, message can be destroyed by user.
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Stores given message to outgoing storage and sends to socket.
Method does not fill session level fields (MsgSeqNum, SenderCompID, etc) After Session::putAsIs returns, message can be destroyed by user.
msg | message to send |
seqNum | Given message sequence number. Session does not update message's sequence number. |
updateOutSeqNum | If true, session will update internal outgoing sequence number. |
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Stores given message to outgoing storage and sends to socket.
Method does not fill session level fields (MsgSeqNum, SenderCompID, etc) After Session::putAsIs returns, message can be destroyed by user.
msg | message to send |
seqNum | Given message sequence number. Session does not update message's sequence number. |
updateOutSeqNum | If true, session will update internal outgoing sequence number. |
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Stores given message to outgoing storage and sends to socket.
Method does not fill session level fields (MsgSeqNum, SenderCompID, etc) After Session::putAsIsNoLock is return, message can be destroyed by user.
msg | message to send |
seqNum | Given message sequence number. Session does not update message's sequence number. |
updateOutSeqNum | If true, session will update internal outgoing sequence number. |
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Stores given message to outgoing storage and sends to socket.
Method does not fill session level fields (MsgSeqNum, SenderCompID, etc) After Session::putAsIsNoLock is return, message can be destroyed by user.
msg | message to send |
seqNum | Given message sequence number. Session does not update message's sequence number. |
updateOutSeqNum | If true, session will update internal outgoing sequence number. |
Method | throws Utils::Exception in case message is incorrect or session is closed. |
|
pure virtual |
Registers Application.
When any application callback executed - new Application coudn't be registered immediately. Session will tries to register new application during delay*triesAmount period.
pNewApplication | Instance of class derived from Application that handles session's events. |
delay | - the time delay in microseconds when session tries to registrate new application |
maxTries | - the amount of attempts during session tries to registrate new application. '-1' means INFINITE attempt. |
|
pure virtual |
Reset messages storage, so nothing will be send on ResendRequest.
|
pure virtual |
Resets sequence numbers according to chosen strategy.
|
static |
Returns the string representation of the given Role value.
|
pure virtual |
Forcedly sets the value of the Enable Message Rejecting.
|
pure virtual |
Forcedly sets the value of the Forced Reconnect.
|
pure virtual |
Forcedly sets the value of the incoming sequence number (the expected MsgSeqNum of the next incoming message).
|
pure virtual |
Forcedly sets the internal state.
|
pure virtual |
Forcedly sets the value of the Intraday Logout Tolerance Mode.
|
pure virtual |
Forcedly sets the value of the outgoing sequence number (MsgSeqNum of the next outgoing message).
|
pure virtual |
Sets the value of the outgoing sequence number (MsgSeqNum of the next outgoing message).
|
pure virtual |
Forcedly sets the value of the Sender Location ID.
|
pure virtual |
Forcedly sets the value of the Sender Sub ID.
|
pure virtual |
|
pure virtual |
Forcedly sets the value of the Target Location ID.
|
pure virtual |
Forcedly sets the value of the Target Sub ID.
|
pure virtual |
Enables or disables TCP buffer.
enable | - when true, TCP buffer will be enabled. |
|
static |
Returns the string representation of the given state value.
|
static |
Converts string to MessageStorageType.
|
static |
Converts string to MessageStorageType.
Case insensitive.
|
pure virtual |
Switch session to the another connection.
When current is a primary - switch to the backup. When current is a backup - switch to the primary.
|
pure virtual |
UnLocks session.
|
pure virtual |
Waits before session gets into any state among provided.
states | - set of states to wait for. |
timeout | - maximal time period to wait for. If it equals to std::chrono::milliseconds::max() then wait forever. |
Returns true if the session got into any of the states requested during timeout preiod and false otherwise
|
pure virtual |
Blocks execution until all threads accittiated with Session are stopped.