OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.9
API Documentation
Session Class Reference

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

Public Member Functions

 Session (const SessionSettings &settings, int marketSegmentId, SessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, SessionStorage *storage=nullptr, UInt64 uuid=UndefinedUuid, const std::string &customKey="")
 
 Session (SessionReactor &stack, const SessionSettings &settings, int marketSegmentId, SessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, SessionStorage *storage=nullptr, UInt64 uuid=UndefinedUuid, const std::string &customKey="")
 
 ~Session ()
 
UInt64 uuid () const noexcept
 
std::string id () const
 
int marketSegmentId () const noexcept
 
std::string customKey () const
 
bool negotiated () const
 
Sessionnegotiated (bool negotiated)
 
Messaging::FTI::Enum faultToleranceIndicator () const
 
SessionfaultToleranceIndicator (Messaging::FTI::Enum value)
 
Sessionconnect (const std::string &host, Port port)
 
Threading::SharedFuture< void > connectAsync (const std::string &host, Port port)
 
Sessiondisconnect (const std::string &reason="")
 
Threading::SharedFuture< void > disconnectAsync (const std::string &reason="")
 
SessionbreakConnection ()
 
Threading::SharedFuture< void > breakConnectionAsync ()
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, Messaging::Timestamp sendingTime=UtcWatch::now())
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, Messaging::Timestamp sendingTime=UtcWatch::now())
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Sessionsend (MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize)
 
Sessionsend (MessageBatchCombiner &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize)
 
SessionsendSequenceMessage (Messaging::KeepAliveLapsed::Enum keepAliveLapsed=Messaging::KeepAliveLapsed::Lapsed)
 
template<typename SbeMessageType , size_t MaxMessageSize>
SessionwarmUp (Messaging::MessageHolder< SbeMessageType, MaxMessageSize > &msg, Messaging::Timestamp sendingTime=UtcWatch::now(), int warmupFlags=0)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
SessionwarmUp (MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize, int warmupFlags=0)
 
SessionwarmUp (MessageBatchCombiner &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize, int warmupFlags=0)
 
Sessionthrottle ()
 
size_t tryThrottle ()
 
SessionthrottlingLimit (size_t messagesCount, size_t intervalInMs=1000)
 
std::string remoteHost () const
 
std::string remoteIpAddress () const
 
Port remotePort () const
 
std::pair< Port, PortlocalPortRange () const noexcept
 
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 noexcept
 
SessionreceiveSpinningTimeout (unsigned timeoutInUs)
 
unsigned sendSpinningTimeout () const noexcept
 
SessionsendSpinningTimeout (unsigned timeoutInUs)
 
bool reportNewMessagesWhileWaitingForMissedMessages () const
 
SessionreportNewMessagesWhileWaitingForMissedMessages (bool value)
 
unsigned messageGrouping () const noexcept
 
SessionmessageGrouping (unsigned numberOfMessagesToGroup)
 
SessionStorageType::Enum storageType () const noexcept
 
const std::string & storageId () const noexcept
 
SeqNumber outSeqNum () const noexcept
 
SessionoutSeqNum (SeqNumber nextOutSeqNum)
 
SeqNumber inSeqNum () const
 
SessioninSeqNum (SeqNumber nextExpectedInSeqNum)
 
SeqNumber previousSeqNo () const noexcept
 
SessionpreviousSeqNo (SeqNumber value)
 
Messaging::UInt64 previousUuid () const noexcept
 
SessionpreviousUuid (Messaging::UInt64 value)
 
Sessionreset (bool startOfWeek=false)
 
SessionStateId::Enum state () const
 
Messaging::Timestamp creationTime () const noexcept
 
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
 
Messaging::Timestamp licenseExpirationDate () const
 
Messaging::SchemaVersion messagingVersion () const noexcept
 
bool detectMessageGapForPreviousUuid () const
 
SessiondetectMessageGapForPreviousUuid (bool detectGap)
 
Handle socketHandle ()
 
size_t outboundQueueBytes ()
 
bool getTcpInfo (TcpInfo &)
 

Static Public Member Functions

static const std::string & version () noexcept
 

Static Public Attributes

static const UInt64 UndefinedUuid = 0
 
static const size_t CmeMaxPacketSize = 1420
 
static const int UndefinedAffinity = -1
 
static const Handle InvalidSocketHandle
 

Friends

struct AdHoc::SessionHelper
 

Detailed Description

Definition at line 47 of file Session.h.

Constructor & Destructor Documentation

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

Constructor.

Parameters
settingsSession settings.
marketSegmentIdMarket segment ID.
listenerSession 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 ( SessionReactor stack,
const SessionSettings settings,
int  marketSegmentId,
SessionListener listener,
SessionStorageType::Enum  storageType = SessionStorageType::FileBased,
SessionStorage storage = nullptr,
UInt64  uuid = UndefinedUuid,
const std::string &  customKey = "" 
)
~Session ( )

Member Function Documentation

Session& breakConnection ( )

Breaks the connection non-gracefully.

Returns
This session.
Threading::SharedFuture<void> breakConnectionAsync ( )

Breaks the connection non-gracefully asynchronously.

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

Establishes the connection.

Parameters
hostMarket Segment Gateway host.
portMarket Segment Gateway port.
Returns
This session.
Threading::SharedFuture<void> connectAsync ( const std::string &  host,
Port  port 
)

Establishes the connection asynchronously.

Parameters
hostMarket Segment Gateway host.
portMarket Segment Gateway port.
Messaging::Timestamp creationTime ( ) const
noexcept
Returns
the time when the session was created or the last reset operation was performed.
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.
bool detectMessageGapForPreviousUuid ( ) const
Returns
the value of the option to detect the message gap for the previous UUID.
Session& detectMessageGapForPreviousUuid ( bool  detectGap)

Sets the value of the option to detect the message gap for the previous UUID.

Session& disconnect ( const std::string &  reason = "")

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.
Threading::SharedFuture<void> disconnectAsync ( const std::string &  reason = "")

Terminates the connection asynchronously.

Parameters
reasonTerminate reason details.
Messaging::FTI::Enum faultToleranceIndicator ( ) const
Returns
the Fault Tolerance Indicator (whether the connection is the primary or backup).
Session& faultToleranceIndicator ( Messaging::FTI::Enum  value)

Sets the Fault Tolerance Indicator (whether the connection is the primary or backup).

void flushSessionStorage ( )

Flushes all internal buffers of the session storage.

bool getTcpInfo ( TcpInfo )

Gets information about the underlying TCP connection.

Returns
true when success; otherwise - false.
Note
Available on Linux only.
Not available for the TcpDirect mode.
std::string id ( ) const
Returns
Session ID (assigned by the exchange).
size_t incomingMessageGapQueueMaximumSize ( ) const
Returns
the maximum size of the message queue used during message gap recovery.
Session& incomingMessageGapQueueMaximumSize ( size_t  value)

Sets the maximum size of the message queue used during message gap recovery.

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.

Messaging::Timestamp licenseExpirationDate ( ) const
Returns
the license expiration date.
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
noexcept
Returns
the local port range
Session& localPortRange ( std::pair< Port, Port portRange)

Sets the local port range.

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
noexcept
Returns
Market Segment ID.
unsigned messageGrouping ( ) const
noexcept
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::iLink3::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.
Messaging::SchemaVersion messagingVersion ( ) const
noexcept
Returns
the version of the message schema.
bool negotiated ( ) const
Returns
true if the session is negotiated (the Negotiation Response message has been received in reply to the Negotiation message); otherwise - false.
Session& negotiated ( bool  negotiated)

Sets the "negotiated" status.

The session is negotiated when the Negotiation Response message has been received in reply to the Negotiation message.

size_t outboundQueueBytes ( )

Returns the total number of bytes in the outbound queue.

SeqNumber outSeqNum ( ) const
noexcept
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
noexcept
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
noexcept
Returns
The UUID from the previously established session.
  • This can be the CME-assigned default UUID=0 for messages published by CME before the first Negotiation of the customer at the beginning of the week.
  • This can be the last UUID 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
noexcept
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,
Messaging::Timestamp  sendingTime = UtcWatch::now() 
)

Sends the message.

Parameters
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
msgThe message to be sent.
Note
This call is thread-safe, except for the TCPDirect mode.
Returns
This session.

Definition at line 640 of file Session.h.

Session & send ( Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&  msg,
Messaging::Timestamp  sendingTime = UtcWatch::now() 
)

Sends the message.

Parameters
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
msgThe message to be sent.
Note
This call is thread-safe, except for the TCPDirect mode.
Returns
This session.

Definition at line 669 of file Session.h.

Session & send ( Messaging::MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > &  msgs,
Messaging::Timestamp  sendingTime = UtcWatch::now(),
size_t  maxPacketSize = CmeMaxPacketSize 
)

Sends messages.

Note
This call is thread-safe.
Parameters
msgsMessage batch to send.
maxPacketSizeThe maximum number of bytes written to the socket's send buffer together. This parameter could be used to reduce the probability that the operating system will fragment the message across multiple TCP packets.
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
Note
The maxPacketSize parameter should not be less than any message size in the batch. Otherwise, the method call can produce an error, and the session can close the connection.
Returns
This session.

Definition at line 683 of file Session.h.

Session& send ( MessageBatchCombiner msgs,
Messaging::Timestamp  sendingTime = UtcWatch::now(),
size_t  maxPacketSize = CmeMaxPacketSize 
)

Sends messages.

Note
This call is thread-safe.
Parameters
msgsMessage batch combiner to send.
maxPacketSizeThe maximum number of bytes written to the socket's send buffer together. This parameter could be used to reduce the probability that the operating system will fragment the message across multiple TCP packets.
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
Note
The maxPacketSize parameter should not be less than any message size in the batch. Otherwise, the method call can produce an error, and the session can close the connection.
Returns
This session.
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.

Send the Sequence message.

Note
The session sends Sequence messages automatically per the CME iLink protocol. This method should be used only if an ad hoc Sequence message is required and the connection is established.
Parameters
keepAliveLapsedIndicates whether one Keep Alive interval has lapsed without any message received.
Returns
This session.
unsigned sendSpinningTimeout ( ) const
noexcept
Returns
the send spinning timeout value (in microseconds).
Session& sendSpinningTimeout ( unsigned  timeoutInUs)

Sets the send spinning timeout value (in microseconds).

Handle socketHandle ( )

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

Note
The TCPDirect mode does not support this method, so it always returns the InvalidSocketHandle value.
const SocketOptions& socketOptions ( ) const
Returns
Socket options.
Session& socketOptions ( const SocketOptions options)

Sets socket options.

SessionStateId::Enum state ( ) const
Returns
Session's current state.
const std::string& storageDirectory ( ) const
Returns
The session storage directory.
const std::string& storageId ( ) const
noexcept
Returns
Session storage ID.
SessionStorageType::Enum storageType ( ) const
noexcept
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).

Session& throttle ( )

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

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

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

Sets throttling limit parameters.

Parameters
messagesCountMessage limit per time unit.
intervalInMsTime interval to limit messages.
Note
This call is thread-safe.
std::string toString ( ) const
Returns
the human-friendly description.
size_t tryThrottle ( )

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

If the count of messages per time unit exceeds the throttling limit, the function returns the delay (in milliseconds) until the sending becomes possible. Otherwise, it returns 0.

Note
This call is thread-safe.
UInt64 uuid ( ) const
noexcept
Returns
the Universally Unique Identifier (UUID).
static const std::string& version ( )
staticnoexcept
Returns
the version of the library.
Session & warmUp ( Messaging::MessageHolder< SbeMessageType, MaxMessageSize > &  msg,
Messaging::Timestamp  sendingTime = UtcWatch::now(),
int  warmupFlags = 0 
)

Warms up the sending path.

Parameters
msgSBE message to warm up the sending path.
warmupFlagsSpecific flags which can be used to turn on the warmup feature for a specific NIC.
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
Note
This call is thread-safe, except for the TCPDirect mode.
Returns
This session.

Definition at line 655 of file Session.h.

Session & warmUp ( Messaging::MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > &  msgs,
Messaging::Timestamp  sendingTime = UtcWatch::now(),
size_t  maxPacketSize = CmeMaxPacketSize,
int  warmupFlags = 0 
)

Warms up the sending path.

Note
This call is thread-safe.
Parameters
msgsMessage batch to send.
maxPacketSizeThe maximum number of bytes written to the socket's send buffer together during the subsequent send call.
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
warmupFlagsSpecific flags which can be used to turn on the warmup feature for a specific NIC.
Note
The maxPacketSize parameter should not be less than any message size in the batch. Otherwise, the method call can produce an error, and the session can close the connection.
Returns
This session.

Definition at line 696 of file Session.h.

Session& warmUp ( MessageBatchCombiner msgs,
Messaging::Timestamp  sendingTime = UtcWatch::now(),
size_t  maxPacketSize = CmeMaxPacketSize,
int  warmupFlags = 0 
)

Warms up the sending path.

Note
This call is thread-safe.
Parameters
msgsMessage batch combiner to send.
maxPacketSizeThe maximum number of bytes written to the socket's send buffer together during the subsequent send call.
sendingTimeThe time value to be used for a sendingTimeEpoch field of the message(s) being sent.
warmupFlagsSpecific flags which can be used to turn on the warmup feature for a specific NIC.
Note
The maxPacketSize parameter should not be less than any message size in the batch. Otherwise, the method call can produce an error, and the session can close the connection.
Returns
This session.

Friends And Related Function Documentation

friend struct AdHoc::SessionHelper
friend

Definition at line 595 of file Session.h.

Member Data Documentation

const size_t CmeMaxPacketSize = 1420
static

CME states: Packet size maximum behavior based on MTU (Maximum Transmission Unit) - 1420 bytes, as defined on our network.

Definition at line 180 of file Session.h.

const Handle InvalidSocketHandle
static

Represents invalid value of socket handle.

Definition at line 556 of file Session.h.

const int UndefinedAffinity = -1
static

Definition at line 364 of file Session.h.

const UInt64 UndefinedUuid = 0
static

Definition at line 50 of file Session.h.


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