OnixS C++ CME MDP Conflated TCP Handler  1.3.6
API Documentation
Session Class Reference

#include <OnixS/CME/ConflatedTCP/Session.h>

Public Member Functions

 Session (const SessionSettings &settings, int marketSegmentId, SessionListener *sessionListener, MDP::MarketDataListener *marketDataListener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, SessionStorage *storage=nullptr, UInt64 uuid=UndefinedUuid, const std::string &customKey="")
 
 ~Session ()
 
UInt64 uuid () const
 
const std::string id () const
 
int marketSegmentId () const
 
const std::string customKey () const
 
Sessionconnect (const std::string &host, Port port)
 
Sessiondisconnect (const std::string &reason="Terminate")
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (Messaging::MessageHolders< SbeMessageType, MaxMessageSize, MessageInitializer > &msgs)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (std::initializer_list< Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > > list)
 
std::string remoteHost () const
 
std::string remoteIpAddress () const
 
Port remotePort () const
 
std::pair< Port, PortlocalPortRange () const
 
SessionlocalPortRange (std::pair< Port, Port > portRange)
 
std::string localNetworkInterface () const
 
SessionlocalNetworkInterface (const std::string &value)
 
Port localPort () const
 
bool tcpNoDelayOption () const
 
SessiontcpNoDelayOption (bool value)
 
const SocketOptionssocketOptions () const
 
SessionsocketOptions (const SocketOptions &options)
 
SessionreceivingThreadAffinity (CpuIndex cpuIndex)
 
SessionreceivingThreadAffinity (const CpuIndexes &cpuIndexes)
 
const CpuIndexesreceivingThreadAffinity () const
 
SessionsendingThreadAffinity (CpuIndex cpuIndex)
 
SessionsendingThreadAffinity (const CpuIndexes &cpuIndexes)
 
const CpuIndexessendingThreadAffinity () const
 
int receivingThreadPriority () const
 
SessionreceivingThreadPriority (int priority)
 
int sendingThreadPriority () const
 
SessionsendingThreadPriority (int priority)
 
int receivingThreadPolicy () const
 
SessionreceivingThreadPolicy (int policy)
 
int sendingThreadPolicy () const
 
SessionsendingThreadPolicy (int policy)
 
unsigned receiveSpinningTimeout () const
 
SessionreceiveSpinningTimeout (unsigned timeoutInUs)
 
unsigned sendSpinningTimeout () const
 
SessionsendSpinningTimeout (unsigned timeoutInUs)
 
bool reportNewMessagesWhileWaitingForMissedMessages () const
 
SessionreportNewMessagesWhileWaitingForMissedMessages (bool value)
 
bool validateSequenceNumbers () const
 
SessionvalidateSequenceNumbers (bool validate)
 
unsigned messageGrouping () const
 
SessionmessageGrouping (unsigned numberOfMessagesToGroup)
 
SessionStorageType::Enum storageType () const
 
const std::string & storageId () const
 
SeqNumber outSeqNum () const
 
SessionoutSeqNum (SeqNumber nextOutSeqNum)
 
SeqNumber inSeqNum () const
 
SessioninSeqNum (SeqNumber nextExpectedInSeqNum)
 
SeqNumber previousSeqNo () const
 
SessionpreviousSeqNo (SeqNumber value)
 
Messaging::UInt64 previousUuid () const
 
SessionpreviousUuid (Messaging::UInt64 value)
 
Sessionreset (bool startOfWeek=false)
 
SessionStateId::Enum state ()
 
Messaging::Timestamp creationTime () const
 
void flushSessionStorage ()
 
unsigned reconnectAttempts () const
 
SessionreconnectAttempts (unsigned reconnectAttempts)
 
unsigned reconnectInterval () const
 
SessionreconnectInterval (unsigned seconds)
 
bool localTimeUsage () const
 
SessionlocalTimeUsage (bool useLocalTime)
 
const std::string & storageDirectory () const
 
bool logBeforeSending () const
 
SessionlogBeforeSending (bool value)
 
size_t incomingMessageGapQueueMaximumSize () const
 
SessionincomingMessageGapQueueMaximumSize (size_t value)
 
const Sessionlog (const std::string &message) const
 
std::string toString () const
 

Static Public Attributes

static const UInt64 UndefinedUuid = 0
 
static const int UndefinedAffinity = -1
 

Detailed Description

Definition at line 38 of file Session.h.

Constructor & Destructor Documentation

Session ( const SessionSettings settings,
int  marketSegmentId,
SessionListener sessionListener,
MDP::MarketDataListener marketDataListener,
SessionStorageType::Enum  storageType = SessionStorageType::FileBased,
SessionStorage storage = nullptr,
UInt64  uuid = UndefinedUuid,
const std::string &  customKey = "" 
)

Constructor.

Parameters
settingsSession settings.
marketSegmentIdMarket segment ID.
sessionListenerSession listener.
marketDataListenerMarket Data listener.
storageTypeSession storage type.
storageSession storage.
uuidUniversally Unique Identifier (UUID).
customKeyCustom key that could be used to distinguish sessions with the same UUID, Session ID, FirmId, and Market Segment ID values.
~Session ( )

Member Function Documentation

Session& connect ( const std::string &  host,
Port  port 
)

Establishes the connection.

Parameters
hostMarket Segment Gateway host.
portMarket Segment Gateway port.
Returns
This session.
Messaging::Timestamp creationTime ( ) const
Returns
the time when the session was created or the last reset operation was performed.
const std::string customKey ( ) const
Returns
Custom key that could be used to distinguish sessions with the same UUID, Session ID, FirmId, and Market Segment ID values.
Session& disconnect ( const std::string &  reason = "Terminate")

Terminates the connection.

Parameters
reasonTerminate reason details.
Note
Method blocks until the Terminate message is received in reply, or the timeout is elapsed.
Returns
This session.
void flushSessionStorage ( )

Flushes all internal buffers of the session storage.

const std::string id ( ) const
Returns
Session ID (assigned by the exchange).
size_t incomingMessageGapQueueMaximumSize ( ) const
Session& incomingMessageGapQueueMaximumSize ( size_t  value)
SeqNumber inSeqNum ( ) const
Returns
the expected sequence number of the next inbound message.
Session& inSeqNum ( SeqNumber  nextExpectedInSeqNum)

Sets the expected sequence number of the next inbound message.

std::string localNetworkInterface ( ) const
Returns
the IP Address or name of the local network interface.
Session& localNetworkInterface ( const std::string &  value)

Sets the IP Address or name of the local network interface.

Port localPort ( ) const
Returns
the local network port number.
std::pair<Port, Port> localPortRange ( ) const
Session& localPortRange ( std::pair< Port, Port portRange)
bool localTimeUsage ( ) const
Returns
the usage of local time in Handler events and logs files.
Session& localTimeUsage ( bool  useLocalTime)

Specifies the usage of local time in Handler events and logs files.

const Session& log ( const std::string &  message) const

Write the given user's message to the Handler's log file using the session formatted Id.

bool logBeforeSending ( ) const
Returns
true if logging of an outgoing message to the session storage is performed before sending it to the wire, otherwise - false.
Session& logBeforeSending ( bool  value)

Sets the option to log an outgoing message to the session storage before sending it to the wire.

int marketSegmentId ( ) const
Returns
Market Segment ID.
unsigned messageGrouping ( ) const
Returns
the number of messages to be sent together.
Session& messageGrouping ( unsigned  numberOfMessagesToGroup)

Sets the number of messages to be sent together.

Parameters
numberOfMessagesToGroupIf the parameter is zero (by default) or one, the Handler tries to send an outgoing application-level message in the context of the thread that calls the OnixS::CME::ConflatedTCP::Session::send method. If the message cannot be sent immediately, it is stored in the queue for the subsequent sending by the sending thread. If this parameter is larger than one, the Handler stores outgoing SBE messages in the queue for the subsequent sending by the sending thread.
Returns
This session.
SeqNumber outSeqNum ( ) const
Returns
the sequence number of the next outgoing message.
Session& outSeqNum ( SeqNumber  nextOutSeqNum)

Sets the sequence number of the next outgoing message.

SeqNumber previousSeqNo ( ) const
Returns
the sequence number of the last business message published by CME with the PreviousUUID.

If no business message was published, the value is zero.

Session& previousSeqNo ( SeqNumber  value)

Sets the sequence number of the last business message published by CME with the PreviousUUID.

Messaging::UInt64 previousUuid ( ) const
Returns
The UUID from the previously Established session.
  • This can be the CME assigned default UUID=0 for messages published by CME before first Negotiation of customer at the beginning of the week.
  • This can be the last UUID as used by the customer from the previously Established session.
Session& previousUuid ( Messaging::UInt64  value)

Sets the UUID from the previously Established session.

unsigned receiveSpinningTimeout ( ) const
Returns
the receive spinning timeout value (in microseconds).
Session& receiveSpinningTimeout ( unsigned  timeoutInUs)

Sets the receive spinning timeout value (in microseconds).

Session& receivingThreadAffinity ( CpuIndex  cpuIndex)

Sets the receiving thread CPU affinity.

Session& receivingThreadAffinity ( const CpuIndexes cpuIndexes)
Returns
the receiving thread CPU affinity.
const CpuIndexes& receivingThreadAffinity ( ) const

Sets the receiving thread CPU affinity.

int receivingThreadPolicy ( ) const
Returns
the receiving thread policy.
Session& receivingThreadPolicy ( int  policy)

Sets the receiving thread policy.

int receivingThreadPriority ( ) const
Returns
the scheduling priority of the receiving thread.
Session& receivingThreadPriority ( int  priority)

Sets the scheduling priority of the receiving thread.

unsigned reconnectAttempts ( ) const
Returns
the maximum number of tries to restore the telecommunications link.
Session& reconnectAttempts ( unsigned  reconnectAttempts)

Sets the maximum number of tries to restore the telecommunications link.

unsigned reconnectInterval ( ) const
Returns
the time interval between retries to restore the telecommunications link (seconds).
Session& reconnectInterval ( unsigned  seconds)

Sets the time interval between retries to restore the telecommunications link (seconds).

std::string remoteHost ( ) const
Returns
the host name the session is connected to.
std::string remoteIpAddress ( ) const
Returns
the IP address the session is connected to.
Port remotePort ( ) const
Returns
the port number the session is connected to.
bool reportNewMessagesWhileWaitingForMissedMessages ( ) const
Returns
true if new messages are reported even when the message gap is detected, and the reply on the Retransmit Request message is expected, otherwise - false.
Session& reportNewMessagesWhileWaitingForMissedMessages ( bool  value)

Sets the option to report new messages even when the message gap is detected, and the reply on the Retransmit Request message is expected.

Session& reset ( bool  startOfWeek = false)

Backups the current log files, resets the sequence numbers to 1 and generates a new UUID.

Warning
Can be called only when the session is disconnected.
Parameters
startOfWeekif true then the PreviousUUID and PreviousSeqNum are reset to 0.
Returns
This session.
Session & send ( Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &  msg)

Sends the message.

Note
This call is thread-safe.
Returns
This session.

Definition at line 380 of file Session.h.

Session & send ( Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&  msg)

Sends the message.

Note
This call is thread-safe.
Returns
This session.

Definition at line 392 of file Session.h.

Session & send ( Messaging::MessageHolders< SbeMessageType, MaxMessageSize, MessageInitializer > &  msgs)

Sends messages.

Note
This call is thread-safe.
Returns
This session.

Definition at line 404 of file Session.h.

Session & send ( std::initializer_list< Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > >  list)

Sends messages.

Note
This call is thread-safe.
Returns
This session.

Definition at line 427 of file Session.h.

Session& sendingThreadAffinity ( CpuIndex  cpuIndex)

Sets the sending thread CPU affinity.

Session& sendingThreadAffinity ( const CpuIndexes cpuIndexes)

Sets the sending thread CPU affinity.

const CpuIndexes& sendingThreadAffinity ( ) const
Returns
the auxiliary sending thread CPU affinity.
int sendingThreadPolicy ( ) const

Sets the sending thread policy.

Session& sendingThreadPolicy ( int  policy)
Returns
the sending thread policy.
int sendingThreadPriority ( ) const
Returns
the scheduling priority of the sending thread.
Session& sendingThreadPriority ( int  priority)
Returns
the scheduling priority of the sending thread.
unsigned sendSpinningTimeout ( ) const
Returns
the send spinning timeout value (in microseconds).
Session& sendSpinningTimeout ( unsigned  timeoutInUs)

Sets the send spinning timeout value (in microseconds).

const SocketOptions& socketOptions ( ) const
Returns
Socket options.
Session& socketOptions ( const SocketOptions options)

Sets socket options.

Returns
Session's current state.
const std::string& storageDirectory ( ) const
Returns
The session storage directory.
const std::string& storageId ( ) const
Returns
Session storage ID.
SessionStorageType::Enum storageType ( ) const
Returns
Session storage type.
bool tcpNoDelayOption ( ) const
Returns
the value of the TCP_NODELAY option (improve latency at the expense of message throughput).
Session& tcpNoDelayOption ( bool  value)

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

std::string toString ( ) const
Returns
the human-friendly description.
UInt64 uuid ( ) const
Returns
the Universally Unique Identifier (UUID).
bool validateSequenceNumbers ( ) const
Returns
true if incoming message sequence numbers are validated, otherwise - false.
Session& validateSequenceNumbers ( bool  validate)

Turns on/off the validation of incoming message sequence numbers.

Member Data Documentation

const int UndefinedAffinity = -1
static

Definition at line 182 of file Session.h.

const UInt64 UndefinedUuid = 0
static

Definition at line 41 of file Session.h.


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