Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends

Engine::Session Class Reference

Basic Session. More...

#include <B2BITS_Session.h>

Inheritance diagram for Engine::Session:
Collaboration diagram for Engine::Session:

List of all members.

Public Types

enum  ActiveConnection { PRIMARY_CONNECTION = 0, BACKUP_CONNECTION, RESTORE_CONNECTION }
 

Active connection to use.

More...
enum  Role { NA, INITIATOR, ACCEPTOR }
 

Defines role of session.

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
}
 

Possible states of Session.

More...

Public Member Functions

virtual void attachStateObserver (SessionStateObserver *observer)=0
virtual void closeMessageStorage ()=0
 Close message storage.
virtual void connect (int HBI, const std::string &host, int port, EncryptMethod encryption=Engine::NONE, const SessionBackupParameters *backupConn=NULL, ActiveConnection activeConn=PRIMARY_CONNECTION)=0
 Establishes the FIX session as Initiator.
virtual void connect (const FixTcpParameters &protocolConfig, const FixTcpBackupParameters *backupConn=NULL)=0
 Establishes the FIX session over FIX_TCP underlying protocol.
virtual void connect (const FixT11TcpParameters &protocolConfig, const FixT11TcpBackupParameters *backupConn=NULL)=0
 Establishes the FIX session over FIXT11_TCP underlying protocol.
virtual void connect (EncryptMethod encryption=Engine::NONE)=0
 Establishes the FIX session as Acceptor.
virtual void connect (int HBI, const FIXMessage &customLogonMsg, const std::string &host, int port, EncryptMethod encryption=Engine::NONE, const SessionBackupParameters *backupConn=NULL, ActiveConnection activeConn=PRIMARY_CONNECTION)=0
 Establishes the FIX session as Initiator using the custom Logon message.
virtual void detachStateObserver ()=0
virtual void disconnect (const std::string &logoutText, bool forcefullyMarkAsTerminated=false)=0
 Initiates disconnect of the session with the given logout text.
virtual void disconnect (bool forcefullyMarkAsTerminated=false)=0
 Initiates disconnect of the session.
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 std::auto_ptr
< SessionExtraParameters
getActiveParameters () const =0
 Returns string representation of active session parameters.
virtual std::auto_ptr
< SessionBackupParameters
getBackupParameters () const =0
 Returns string representation of backup session parameters.
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'.
virtual int getInSeqNum () const =0
 Returns the incoming sequence numbers for this FIX session (the expected MsgSeqNum of the next incoming message).
virtual const std::string * getMsgStorageName () const =0
virtual int getOutSeqNum () const =0
 Returns the outgoing sequence numbers for this FIX session (MsgSeqNum of the next outgoing message).
virtual std::auto_ptr
< SessionExtraParameters
getPrimaryParameters () const =0
 Returns 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 const System::InetAddress & getRemoteAddress () const =0
 Returns the remote FIX Engine's IP Address.
virtual const std::string * getRemoteHost ()=0
 Returns the remote FIX Engine's host name.
virtual IPAddr getRemoteHostIP () const
 Returns the remote FIX Engine's IP Address.
virtual int getRemotePort ()=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 ()
virtual State getState () const =0
 Returns session's state;.
virtual const char * getStateAsString ()=0
 Returns current session's state as string;.
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 isTCPBuffer () const =0
virtual FIXMessagelocateSentMessage (int seqNum) const =0
virtual FIXMessagenewSkel (const char *msgType, Engine::FIXVersion app_ver=Engine::NA) const =0
 Creates instance of the message withe same protocol as session is.
virtual size_t outgoingQueueSize () const =0
 Returns size of the outgoing message queue.
virtual void ping (const std::string &testReqID="")=0
 Sends Test Request message.
virtual ProtocolID protocolID () const =0
 Returns unique protocol identifier of the session.
virtual void put (PreparedMessage *pMsg)=0
 Sends the given message to the remote FIX engine.
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 ApplicationregisterApplication (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 ()=0
 Sends the Logon message with the ResetSeqNumFlag flat that indicates both sides of a FIX session should reset sequence numbers.
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 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 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 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.

Static Public Member Functions

static const char * connState2string (ActiveConnection aState)
 Returns the string representation of the given connection state value.
static const char * state2string (State state)
 Returns the string representation of the given state value.

Protected Member Functions

 Session ()
 Constructor.
virtual ~Session ()
 Destructor.

Friends

class SessionDataProvider

Detailed Description

Basic Session.

Definition at line 108 of file B2BITS_Session.h.


Member Enumeration Documentation

Active connection to use.

Enumerator:
PRIMARY_CONNECTION 

The session connects via primary connection.

BACKUP_CONNECTION 

The session connects via backup connection.

RESTORE_CONNECTION 

The session connects to the previous active connection.

Definition at line 121 of file B2BITS_Session.h.

Defines role of session.

Enumerator:
NA 

NA.

INITIATOR 

Session is acceptor.

ACCEPTOR 

Session is initiator.

Definition at line 449 of file B2BITS_Session.h.

Possible states of Session.

See also:
Session::state2string(State state).
Enumerator:
ESTABLISHED 

The session is fully established.

INITIAL 

The session has been created, but has not been connected yet.

NON_GRACEFULLY_TERMINATED 

The session has been non-gracefully terminated.

RECONNECT 

The session-initiator has detected the telecommunication link error and is trying to re-establish the link.

CORRECTLY_TERMINATED 

The session has been correctly terminated.

WAIT_FOR_CONFIRM_LOGON 

The session has been connected as an Initiator, the first Logon message has been sent and it is waiting for the conforming Logon message.

WAIT_FOR_CONFIRM_LOGOUT 

Waiting for confirm logout state.

WAIT_FOR_FIRST_LOGON 

The session has been connected as an Acceptor and is waiting for the first Logon message.

SWITCH_CONNECTION 

The session switch to the another connection (backup or primary)

WAIT_FOR_FIRST_HELLO 

The session has been connected as an Acceptor and is waiting for the first Hello message.

WAIT_FOR_CONFIRM_HELLO 

The session has been connected as an Initiator, the first FAST Hello message has been sent and it is waiting for the conforming Hello message.

Definition at line 289 of file B2BITS_Session.h.


Constructor & Destructor Documentation

Engine::Session::Session (  ) [inline, protected]

Constructor.

Definition at line 542 of file B2BITS_Session.h.

virtual Engine::Session::~Session (  ) [inline, protected, virtual]

Destructor.

Note:
It is necessary to call the 'release()' method to free the resources used by this session.

Definition at line 549 of file B2BITS_Session.h.


Member Function Documentation

virtual void Engine::Session::attachStateObserver ( SessionStateObserver *  observer ) [pure virtual]
virtual void Engine::Session::closeMessageStorage (  ) [pure virtual]

Close message storage.

Method forcidly closes storage if session is in the NGT/CT state.

virtual void Engine::Session::connect ( int  HBI,
const std::string &  host,
int  port,
EncryptMethod  encryption = Engine::NONE,
const SessionBackupParameters backupConn = NULL,
ActiveConnection  activeConn = PRIMARY_CONNECTION 
) [pure virtual]

Establishes the FIX session as Initiator.

Parameters:
HBIHeartbeat interval (seconds)
hostremote FIX engine's host name or address.
portremote FIX engine's port.
encryptionEncrypt method.
backupConn- parameters of the backup connection
activeConn- specifies which connection will be used, by default primary connection
virtual void Engine::Session::connect ( const FixTcpParameters protocolConfig,
const FixTcpBackupParameters backupConn = NULL 
) [pure virtual]

Establishes the FIX session over FIX_TCP underlying protocol.

Parameters:
protocolConfig- set of the FIX_TCP protocol parameters.
backupConn- parameters of the backup connection
virtual void Engine::Session::connect ( const FixT11TcpParameters protocolConfig,
const FixT11TcpBackupParameters backupConn = NULL 
) [pure virtual]

Establishes the FIX session over FIXT11_TCP underlying protocol.

Parameters:
protocolConfig- set of the FIXT11_TCP protocol parameters.
backupConn- parameters of the backup connection
virtual void Engine::Session::connect ( EncryptMethod  encryption = Engine::NONE ) [pure virtual]

Establishes the FIX session as Acceptor.

Parameters:
encryptionEncrypt method.
virtual void Engine::Session::connect ( int  HBI,
const FIXMessage customLogonMsg,
const std::string &  host,
int  port,
EncryptMethod  encryption = Engine::NONE,
const SessionBackupParameters backupConn = NULL,
ActiveConnection  activeConn = PRIMARY_CONNECTION 
) [pure virtual]

Establishes the FIX session as Initiator using the custom Logon message.

Parameters:
HBIHeartbeat interval (in seconds)
customLogonMsgthe custom Logon message.
hostremote FIX engine's host name or address.
portremote FIX engine's port.
encryptionEncrypt method.
backupConn- parameters of the backup connection
activeConn- specifies which connection will be used, by default primary connection
static const char* Engine::Session::connState2string ( ActiveConnection  aState ) [static]

Returns the string representation of the given connection state value.

virtual void Engine::Session::detachStateObserver (  ) [pure virtual]
virtual void Engine::Session::disconnect ( const std::string &  logoutText,
bool  forcefullyMarkAsTerminated = false 
) [pure virtual]

Initiates disconnect of the session with the given logout text.

Parameters:
forcefullyMarkAsTerminatedif true then the session will be marked as correctly terminated and persistant
logoutTextReason of disconnecting information about it will not be used during the subsequent connections.
Note:
the forcefullyMarkAsTerminated parameter is used only if the IntradayLogoutTolerance configuration option is "false".
virtual void Engine::Session::disconnect ( bool  forcefullyMarkAsTerminated = false ) [pure virtual]

Initiates disconnect of the session.

Parameters:
forcefullyMarkAsTerminatedif true then the session will be marked as correctly terminated and persistant information about it will not be used during the subsequent connections.
Note:
the forcefullyMarkAsTerminated parameter is used only if the IntradayLogoutTolerance configuration option is "false".
virtual void Engine::Session::disconnectNonGracefully (  ) [pure virtual]

Closes the telecommunication link and switches the session into the NON_GRACEFULLY_TERMINATED state.

virtual void Engine::Session::disconnectSync ( bool  forcefullyMarkAsTerminated = false ) [virtual]

Initiates synchronous disconnect of the session.

Parameters:
forcefullyMarkAsTerminatedif true then the session will be marked as correctly terminated and persistant information about it will not be used during the subsequent connections.
Note:
the forcefullyMarkAsTerminated parameter is used only if the IntradayLogoutTolerance configuration option is "false".
virtual void Engine::Session::disconnectSync ( const std::string &  logoutText,
bool  forcefullyMarkAsTerminated = false 
) [virtual]

Initiates synchronous disconnect of the session with the given logout text.

Parameters:
forcefullyMarkAsTerminatedif true then the session will be marked as correctly terminated and persistant
logoutTextReason of disconnecting information about it will not be used during the subsequent connections.
Note:
the forcefullyMarkAsTerminated parameter is used only if the IntradayLogoutTolerance configuration option is "false".
virtual ActiveConnection Engine::Session::getActiveConnectionType (  ) const [pure virtual]

Returns current connection type.

virtual std::auto_ptr<SessionExtraParameters> Engine::Session::getActiveParameters (  ) const [pure virtual]

Returns string representation of active session parameters.

Returns:
string representation of active session parameters or NULL if parameters not exist
virtual std::auto_ptr<SessionBackupParameters> Engine::Session::getBackupParameters (  ) const [pure virtual]

Returns string representation of backup session parameters.

Returns:
string representation of backup session parameters or NULL if parameters not exist
virtual Engine::EncryptMethod Engine::Session::getEncryptionMethod (  ) const [pure virtual]

Returns the encryption method.

virtual int Engine::Session::getHBI (  ) const [pure virtual]

Returns Heartbeat interval (HeartBtInt) in seconds.

virtual const std::string* Engine::Session::getId (  ) const [pure virtual]

Returns the session's ID in the format 'SenderCompID 0x01 TargetCompId'.

virtual int Engine::Session::getInSeqNum (  ) const [pure virtual]

Returns the incoming sequence numbers for this FIX session (the expected MsgSeqNum of the next incoming message).

virtual const std::string* Engine::Session::getMsgStorageName (  ) const [pure virtual]
virtual int Engine::Session::getOutSeqNum (  ) const [pure virtual]

Returns the outgoing sequence numbers for this FIX session (MsgSeqNum of the next outgoing message).

virtual std::auto_ptr<SessionExtraParameters> Engine::Session::getPrimaryParameters (  ) const [pure virtual]

Returns string representation of primary session parameters.

Returns:
string representation of primary session parameters or NULL if parameters not exist
virtual void Engine::Session::getReceivedMessages ( std::vector< FIXMessage * > *  pMessages,
const MsgFilter msgFilter 
) const [pure virtual]

Retrieves messages received by the session.

Parameters:
pMessagesList of messages.
msgFilterspecifies selection criteria.
Warning:
It's caller's responsibility to release returned messages.
virtual const System::InetAddress& Engine::Session::getRemoteAddress (  ) const [pure virtual]

Returns the remote FIX Engine's IP Address.

Exceptions:
Utils::Exceptionif no data is available
virtual const std::string* Engine::Session::getRemoteHost (  ) [pure virtual]

Returns the remote FIX Engine's host name.

Exceptions:
Utils::Exceptionif no data is available
virtual IPAddr Engine::Session::getRemoteHostIP (  ) const [virtual]

Returns the remote FIX Engine's IP Address.

Exceptions:
Utils::Exceptionif no data is available
virtual int Engine::Session::getRemotePort (  ) [pure virtual]

Returns the remote FIX Engine's port number.

virtual Role Engine::Session::getRole (  ) const [pure virtual]

Returns session's role.

virtual const std::string* Engine::Session::getSender (  ) const [pure virtual]

Returns SenderCompID.

virtual SessionEx* Engine::Session::getSessionEx (  ) [virtual]
virtual State Engine::Session::getState (  ) const [pure virtual]

Returns session's state;.

See also:
Session::state2string(State).
virtual const char* Engine::Session::getStateAsString (  ) [pure virtual]

Returns current session's state as string;.

See also:
Session::getState()
virtual MessageStorageType Engine::Session::getStorageType (  ) const [pure virtual]

Returns a session storage type.

virtual const std::string* Engine::Session::getTarget (  ) const [pure virtual]

Returns TargetCompID.

virtual UnderlyingProtocol Engine::Session::getUnderlyingProtocol (  ) const [pure virtual]

Returns type of the underlying protocol.

virtual FIXVersion Engine::Session::getVer (  ) const [pure virtual]

Returns the FIX protocol version.

virtual void Engine::Session::inflate ( FIXMessage pMsg,
int  msgSeqNumSize,
PutMessageOptions const *  options = NULL 
) const [pure virtual]

Sets static session level fields in the message and reserves space for volatile session level fields.

Parameters:
[out]pMsgPointer to the FIXMessage to store field values
[in]msgSeqNumSizeNumber of characters for MsgSeqNum field to reserve.
[in]optionsExtra parameters.
See also:
Engine::PutMessageOptions.
virtual bool Engine::Session::isTCPBuffer (  ) const [pure virtual]
virtual FIXMessage* Engine::Session::locateSentMessage ( int  seqNum ) const [pure virtual]
virtual FIXMessage* Engine::Session::newSkel ( const char *  msgType,
Engine::FIXVersion  app_ver = Engine::NA 
) const [pure virtual]

Creates instance of the message withe same protocol as session is.

virtual size_t Engine::Session::outgoingQueueSize (  ) const [pure virtual]

Returns size of the outgoing message queue.

Returns:
size of the outgoing message queue.
virtual void Engine::Session::ping ( const std::string &  testReqID = "" ) [pure virtual]

Sends Test Request message.

Parameters:
testReqIDThe TestReqID field (tag = 112) - Identifier included in Test Request message to be returned in resulting Heartbeat message. If empty then a timestamp string will be used as the value.
virtual ProtocolID Engine::Session::protocolID (  ) const [pure virtual]

Returns unique protocol identifier of the session.

virtual void Engine::Session::put ( PreparedMessage pMsg ) [pure virtual]

Sends the given message to the remote FIX engine.

Warning:
Method throws Utils::Exception in case message is incorrect or session is closed.
virtual void Engine::Session::put ( const std::string &  msgHeader,
const std::string &  msgBody 
) [pure virtual]

Sends the given message to the remote FIX engine.

Parameters:
msgHeaderthe message header in the native FIX format.
msgBodythe message body in the native FIX format.
Warning:
msgHeader and msgBody must be terminated by the FIX delimiter character (0x001).
msgHeader must contain at least the 'BeginString' and 'MsgType' fields.
Method throws Utils::Exception in case message is incorrect or session is closed.
virtual void Engine::Session::put ( FIXMessage pMsg,
PutMessageOptions const *  options = NULL 
) [pure virtual]

Sends the given message to the remote FIX engine.

Warning:
Method throws Utils::Exception in case message is incorrect or session is closed.
virtual Application* Engine::Session::registerApplication ( Application pNewApplication,
unsigned int  delay = 300,
int  maxTries = -1 
) [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.

Parameters:
pNewApplicationInstance 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.
Warning:
It is vital to call 'registerApplication(NULL)' before calling the 'release' method.
Returns:
a pointer to the old application.
virtual void Engine::Session::resetMessageStorage (  ) [pure virtual]

Reset messages storage, so nothing will be send on ResendRequest.

virtual void Engine::Session::resetSeqNum (  ) [pure virtual]

Sends the Logon message with the ResetSeqNumFlag flat that indicates both sides of a FIX session should reset sequence numbers.

Warning:
cannot be used with FIX40.
virtual void Engine::Session::setEnableMessageRejecting ( bool  enable ) [pure virtual]

Forcedly sets the value of the Enable Message Rejecting.

virtual void Engine::Session::setForcedReconnect ( bool  enable ) [pure virtual]

Forcedly sets the value of the Forced Reconnect.

virtual void Engine::Session::setInSeqNum ( int  seqNum ) [pure virtual]

Forcedly sets the value of the incoming sequence number (the expected MsgSeqNum of the next incoming message).

virtual void Engine::Session::setIntradayLogoutToleranceMode ( bool  enable ) [pure virtual]

Forcedly sets the value of the Intraday Logout Tolerance Mode.

virtual void Engine::Session::setOutSeqNum ( int  seqNum ) [pure virtual]

Forcedly sets the value of the outgoing sequence number (MsgSeqNum of the next outgoing message).

virtual void Engine::Session::setSenderLocationID ( const std::string &  id ) [pure virtual]

Forcedly sets the value of the Sender Location ID.

virtual void Engine::Session::setSenderSubID ( const std::string &  id ) [pure virtual]

Forcedly sets the value of the Sender Sub ID.

virtual void Engine::Session::setTargetLocationID ( const std::string &  id ) [pure virtual]

Forcedly sets the value of the Target Location ID.

virtual void Engine::Session::setTargetSubID ( const std::string &  id ) [pure virtual]

Forcedly sets the value of the Target Sub ID.

virtual bool Engine::Session::setTCPBuffer ( bool  enable ) [pure virtual]

Enables or disables TCP buffer.

Parameters:
enable- when true, TCP buffer will be enabled.
Returns:
true, if TCP buffer was enabled before.
static const char* Engine::Session::state2string ( State  state ) [static]

Returns the string representation of the given state value.

virtual void Engine::Session::switchConnection (  ) [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.


Friends And Related Function Documentation

friend class SessionDataProvider [friend]

Definition at line 109 of file B2BITS_Session.h.