OnixS C++ B3 BOE Binary Order Entry 1.3.0
API Documentation
Loading...
Searching...
No Matches
Gateway Class Reference

Public Types

using Timeout = std::chrono::milliseconds

Public Member Functions

 Gateway (const SessionSettings::LicenseStores &licenseStores, int port, const char *host="127.0.0.1", const Timeout &acceptTimeout=defaultTimeout(), const Timeout &sendReceiveTimeout=defaultTimeout())
virtual ~Gateway ()
 Gateway (const Gateway &)=delete
Gatewayoperator= (const Gateway &)=delete
 Gateway (Gateway &&) noexcept
Gatewayoperator= (Gateway &&) noexcept
void swap (Gateway &) noexcept
GatewayacceptConnection (const Timeout &acceptTimeout=defaultTimeout())
bool tryAcceptConnection (const Timeout &acceptTimeout=defaultTimeout())
GatewayacceptSession (SeqNumber outgoingSequenceNumber=1)
Terminate7Ptr waitUntilTerminate (ClientMessageListener *listener=nullptr, ClientSessionMessageListener *sessionMessageListener=nullptr, std::atomic< bool > *stopRequested=nullptr)
GatewaysendSequence (UInt32 nextSeqNo)
Gatewaydisconnect ()
const char * host () const noexcept
int port () const noexcept
GatewayenableLogger (const std::string &logFileName, unsigned int logLevel=3)
template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gatewaysend (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg)
template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gatewaysend (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg)
template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gatewaysend (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, SeqNumber num)
template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gatewaysend (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, SeqNumber num)
template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gatewaysend (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, std::initializer_list< SeqNumber > numbers)
template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gatewaysend (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, std::initializer_list< SeqNumber > numbers)
template<typename TMsg>
MessagePtr< TMsg > receiveTypedMessage ()
Gatewayrun (ClientMessageListener &listener)
Gatewayrun (ClientMessageListener &appMsgListener, ClientSessionMessageListener &sessionMsgListener)
SeqNumber outSeqNum () const noexcept
GatewayoutSeqNum (SeqNumber nextOutSeqNum) noexcept
UInt64 sessionVerId () const noexcept
SessionID sessionId () const noexcept
GatewaytcpNoDelayOption (bool noDelay)
bool tcpNoDelayOption () const noexcept
int socketReceiveBufferSize () const
GatewaysocketReceiveBufferSize (int bufferSize)
int socketSendBufferSize () const noexcept
GatewaysocketSendBufferSize (int bufferSize)

Protected Member Functions

bool isConnectionClosed (const Timeout &timeout) const
bool isConnectionClosed () const
MessageBasePtr receive () const
MessageBasePtr tryReceive (const Timeout &timeout=defaultTimeout()) const
Negotiate1Ptr receiveNegotiate ()
Negotiate1Ptr acceptNegotiate ()
Negotiate1Ptr rejectNegotiate (NegotiationRejectCode::Enum errorCodes=NegotiationRejectCode::Enum())
Establish4Ptr receiveEstablish ()
Establish4Ptr acceptEstablish (UInt32 outgoingSequenceNumber=1, unsigned gatewayKeepAliveInterval=0)
Establish4Ptr rejectEstablish (UInt32 outgoingSequenceNumber=1, EstablishRejectCode::Enum errorCodes=EstablishRejectCode::Enum())
Terminate7Ptr receiveTerminate ()
Terminate7Ptr acceptTerminate ()
GatewaysendTerminate (TerminationCode::Enum errCode=TerminationCode::Finished)
Terminate7Ptr terminate (TerminationCode::Enum errCode=TerminationCode::Finished)
NegotiateResponse2Container createNegotiationResponse (const Negotiate1Ptr &request)
NegotiateReject3Container createNegotiateReject (const Negotiate1Ptr &request, NegotiationRejectCode::Enum errorCodes)
EstablishAck5Container createEstablishmentAck (const Establish4Ptr &request, UInt32 outgoingSequenceNumber, unsigned gatewayKeepAliveInterval=0)
EstablishReject6Container createEstablishReject (const Establish4Ptr &request, UInt32 outgoingSequenceNumber, EstablishRejectCode::Enum errorCodes)
Terminate7Container createTerminate (const Terminate7Ptr &request)
Terminate7Container createTerminate (TerminationCode::Enum errCode)
Sequence9Container createSequence (UInt32 nextSeqNo)
Gatewaysend (Messaging::SbeMessage, Messaging::SimpleOpenFramingHeader &)
GatewaysendData (const void *data, size_t size)
Gatewayclose ()

Static Protected Member Functions

static Timeout defaultTimeout ()

Protected Attributes

UInt64 uId_ {0}
SessionID sessionId_

Detailed Description

Definition at line 66 of file Gateway.h.

Member Typedef Documentation

◆ Timeout

using Timeout = std::chrono::milliseconds

Timeout alias.

Definition at line 70 of file Gateway.h.

Constructor & Destructor Documentation

◆ Gateway() [1/3]

Gateway ( const SessionSettings::LicenseStores & licenseStores,
int port,
const char * host = "127.0.0.1",
const Timeout & acceptTimeout = defaultTimeout(),
const Timeout & sendReceiveTimeout = defaultTimeout() )

◆ ~Gateway()

virtual ~Gateway ( )
virtual

◆ Gateway() [2/3]

Gateway ( const Gateway & )
delete

Deleted.

◆ Gateway() [3/3]

Gateway ( Gateway && )
noexcept

Move semantic.

Member Function Documentation

◆ acceptConnection()

Gateway & acceptConnection ( const Timeout & acceptTimeout = defaultTimeout())

Accepts an incoming connection.

If the acceptTimeout is zero, the acceptTimeout provided in the constructor is used.

◆ acceptEstablish()

Establish4Ptr acceptEstablish ( UInt32 outgoingSequenceNumber = 1,
unsigned gatewayKeepAliveInterval = 0 )
protected

Receive the Establish4 message and respond with the EstablishAck5 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ acceptNegotiate()

Negotiate1Ptr acceptNegotiate ( )
protected

Receives the Negotiate1 and responds with the NegotiateResponse2 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ acceptSession()

Gateway & acceptSession ( SeqNumber outgoingSequenceNumber = 1)

Accepts an incoming FIXP session.

◆ acceptTerminate()

Terminate7Ptr acceptTerminate ( )
protected

Receive the Terminate7 message and responds with the Terminate7 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ close()

Gateway & close ( )
protected

Close the listening socket.

◆ createEstablishmentAck()

EstablishAck5Container createEstablishmentAck ( const Establish4Ptr & request,
UInt32 outgoingSequenceNumber,
unsigned gatewayKeepAliveInterval = 0 )
protected

Creates a EstablishAck5 message.

◆ createEstablishReject()

EstablishReject6Container createEstablishReject ( const Establish4Ptr & request,
UInt32 outgoingSequenceNumber,
EstablishRejectCode::Enum errorCodes )
protected

Creates a EstablishReject6 message.

◆ createNegotiateReject()

NegotiateReject3Container createNegotiateReject ( const Negotiate1Ptr & request,
NegotiationRejectCode::Enum errorCodes )
protected

Creates a NegotiateReject3 message.

◆ createNegotiationResponse()

NegotiateResponse2Container createNegotiationResponse ( const Negotiate1Ptr & request)
protected

Creates a NegotiateResponse2 message.

◆ createSequence()

Sequence9Container createSequence ( UInt32 nextSeqNo)
protected

Creates a Sequence9 message.

◆ createTerminate() [1/2]

Terminate7Container createTerminate ( const Terminate7Ptr & request)
protected

Creates a Terminate7 message.

◆ createTerminate() [2/2]

Terminate7Container createTerminate ( TerminationCode::Enum errCode)
protected

Creates a Terminate7 message.

◆ defaultTimeout()

Timeout defaultTimeout ( )
inlinestaticprotected

Default timeout.

Definition at line 324 of file Gateway.h.

◆ disconnect()

Gateway & disconnect ( )

Closes the accepted connection.

◆ enableLogger()

Gateway & enableLogger ( const std::string & logFileName,
unsigned int logLevel = 3 )

Enables logging.

◆ host()

const char * host ( ) const
noexcept
Returns
listen host.

◆ isConnectionClosed() [1/2]

bool isConnectionClosed ( ) const
protected

Checks whether the connection is closed by the counterparty using the default timeout (provided in the constructor).

◆ isConnectionClosed() [2/2]

bool isConnectionClosed ( const Timeout & timeout) const
protected

Checks whether the connection is closed by the counterparty.

◆ operator=() [1/2]

Gateway & operator= ( const Gateway & )
delete

◆ operator=() [2/2]

Gateway & operator= ( Gateway && )
noexcept

◆ outSeqNum() [1/2]

SeqNumber outSeqNum ( ) const
noexcept
Returns
the sequence number of the next outgoing message.

◆ outSeqNum() [2/2]

Gateway & outSeqNum ( SeqNumber nextOutSeqNum)
noexcept

Sets the sequence number of the next outgoing message.

◆ port()

int port ( ) const
noexcept
Returns
the listen port.

◆ receive()

MessageBasePtr receive ( ) const
protected

Receives a message.

◆ receiveEstablish()

Establish4Ptr receiveEstablish ( )
protected

Receives the Establish4 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ receiveNegotiate()

Negotiate1Ptr receiveNegotiate ( )
protected

Receives the Negotiate1 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ receiveTerminate()

Terminate7Ptr receiveTerminate ( )
protected

Receive the Terminate7 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ receiveTypedMessage()

template<typename TMsg>
MessagePtr< TMsg > receiveTypedMessage ( )

Receives the message of the particular type.

Exceptions
std::logic_errorif an unexpected type is received.

Definition at line 343 of file Gateway.h.

◆ rejectEstablish()

Establish4Ptr rejectEstablish ( UInt32 outgoingSequenceNumber = 1,
EstablishRejectCode::Enum errorCodes = EstablishRejectCode::Enum() )
protected

Receives the Establish4 message and responds with the EstablishReject6 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ rejectNegotiate()

Negotiate1Ptr rejectNegotiate ( NegotiationRejectCode::Enum errorCodes = NegotiationRejectCode::Enum())
protected

Receives the Negotiate1 message and responds with the NegotiateReject3 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ run() [1/2]

Gateway & run ( ClientMessageListener & appMsgListener,
ClientSessionMessageListener & sessionMsgListener )

Accepts an incoming connection and establishes the session.

  • Receives and reports application-level messages via the corresponding callback.
  • Receives and reports session-level messages via the corresponding callback.
  • Sends Sequence messages.

◆ run() [2/2]

Gateway & run ( ClientMessageListener & listener)

Accepts an incoming connection and establishes the session.

  • Receives and reports application-level messages via the corresponding callback.
  • Sends Sequence messages in response to the received ones.

◆ send() [1/7]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gateway & send ( BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && msg)

Sends the given message.

Note
does not update outSeqNum.

Definition at line 359 of file Gateway.h.

◆ send() [2/7]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gateway & send ( BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && msg,
SeqNumber num )

Sets the given sequence number and sends the message.

Note
does not update outSeqNum.

Definition at line 373 of file Gateway.h.

◆ send() [3/7]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gateway & send ( BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && msg,
std::initializer_list< SeqNumber > numbers )

Sets the given sequence numbers and sends the messages.

Note
does not update outSeqNum.

Definition at line 393 of file Gateway.h.

◆ send() [4/7]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gateway & send ( BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & msg)

Sends the given message.

Note
does not update outSeqNum.

Definition at line 349 of file Gateway.h.

◆ send() [5/7]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gateway & send ( BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & msg,
SeqNumber num )

Sets the given sequence number and sends the message.

Note
does not update outSeqNum.

Definition at line 365 of file Gateway.h.

◆ send() [6/7]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
Gateway & send ( BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & msg,
std::initializer_list< SeqNumber > numbers )

Sets the given sequence numbers and sends the messages.

Note
does not update outSeqNum.

Definition at line 381 of file Gateway.h.

◆ send() [7/7]

Sends the given message.

◆ sendData()

Gateway & sendData ( const void * data,
size_t size )
protected

Sends the given data.

◆ sendSequence()

Gateway & sendSequence ( UInt32 nextSeqNo)

Sends the Sequence9 message.

◆ sendTerminate()

Gateway & sendTerminate ( TerminationCode::Enum errCode = TerminationCode::Finished)
protected

Sends the Terminate7 message.

◆ sessionId()

SessionID sessionId ( ) const
inlinenoexcept
Returns
session Id.

Definition at line 192 of file Gateway.h.

◆ sessionVerId()

UInt64 sessionVerId ( ) const
inlinenoexcept
Returns
sessionVerId.

Definition at line 185 of file Gateway.h.

◆ socketReceiveBufferSize() [1/2]

int socketReceiveBufferSize ( ) const
Returns
the socket receive buffer size.

The default value is SessionSettings::Default::SocketReceiveBufferSize.

◆ socketReceiveBufferSize() [2/2]

Gateway & socketReceiveBufferSize ( int bufferSize)

Sets the socket receive buffer size.

Parameters
bufferSizethe size of the socket receive buffer size. If SessionSettings::UseOsDefaultSocketBufferSize then the default operating system value is used.

◆ socketSendBufferSize() [1/2]

int socketSendBufferSize ( ) const
noexcept
Returns
the size of the socket send buffer size.

The default value is SessionSettings::Default::SocketSedndBufferSize.

◆ socketSendBufferSize() [2/2]

Gateway & socketSendBufferSize ( int bufferSize)

Sets the size of the socket send buffer size.

Parameters
bufferSizethe size of the socket send buffer size. If SessionSettings::UseOsDefaultSocketBufferSize then the default operating system value is used.

◆ swap()

void swap ( Gateway & )
noexcept

Swap with other.

◆ tcpNoDelayOption() [1/2]

bool tcpNoDelayOption ( ) const
noexcept
Returns
the value of the option to improve latency at the expense of message throughput (the TCP_NODELAY socket option).

The default value is SessionSettings::Default::TcpNoDelayOption.

◆ tcpNoDelayOption() [2/2]

Gateway & tcpNoDelayOption ( bool noDelay)

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

◆ terminate()

Sends the Terminate7 message and waits until the response is received.

◆ tryAcceptConnection()

bool tryAcceptConnection ( const Timeout & acceptTimeout = defaultTimeout())

Accepts an incoming connection.

If the operation is timed out, false is returned.

◆ tryReceive()

MessageBasePtr tryReceive ( const Timeout & timeout = defaultTimeout()) const
protected

Receives a message using the provided timeout.

If the operation is timed out, an empty message is returned.

◆ waitUntilTerminate()

Terminate7Ptr waitUntilTerminate ( ClientMessageListener * listener = nullptr,
ClientSessionMessageListener * sessionMessageListener = nullptr,
std::atomic< bool > * stopRequested = nullptr )

Waits until the Terminate7 message is received.

If the listener is provided, then receives and reports application-level messages via the corresponding callback. Responds to the Sequence9 message if received.

Note
actual outSeqNum must be provided before invocation

Member Data Documentation

◆ sessionId_

SessionID sessionId_
protected

sessionId.

Definition at line 333 of file Gateway.h.

◆ uId_

UInt64 uId_ {0}
protected

sessionVerId.

Definition at line 330 of file Gateway.h.