OnixS C++ B3 BOE Binary Order Entry  1.2.0
API Documentation
Gateway Class Reference

#include <OnixS/B3/BOE/testing/Gateway.h>

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

using Timeout = std::chrono::milliseconds

Timeout alias.

Definition at line 70 of file Gateway.h.

Constructor & Destructor Documentation

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

Deleted.

Gateway ( Gateway &&  )
noexcept

Move semantic.

Member Function Documentation

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

Accepts an incoming connection.

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

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.
Negotiate1Ptr acceptNegotiate ( )
protected

Receives the Negotiate1 and responds with the NegotiateResponse2 message.

Exceptions
std::logic_errorif an unexpected type is received.
Gateway& acceptSession ( SeqNumber  outgoingSequenceNumber = 1)

Accepts an incoming FIXP session.

Terminate7Ptr acceptTerminate ( )
protected

Receive the Terminate7 message and responds with the Terminate7 message.

Exceptions
std::logic_errorif an unexpected type is received.
Gateway& close ( )
protected

Close the listening socket.

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

Creates a EstablishAck5 message.

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

Creates a EstablishReject6 message.

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

Creates a NegotiateReject3 message.

NegotiateResponse2Container createNegotiationResponse ( const Negotiate1Ptr request)
protected

Creates a NegotiateResponse2 message.

Sequence9Container createSequence ( UInt32  nextSeqNo)
protected

Creates a Sequence9 message.

Terminate7Container createTerminate ( const Terminate7Ptr request)
protected

Creates a Terminate7 message.

Terminate7Container createTerminate ( TerminationCode::Enum  errCode)
protected

Creates a Terminate7 message.

static Timeout defaultTimeout ( )
inlinestaticprotected

Default timeout.

Definition at line 324 of file Gateway.h.

Gateway& disconnect ( )

Closes the accepted connection.

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

Enables logging.

const char* host ( ) const
noexcept
Returns
listen host.
bool isConnectionClosed ( const Timeout timeout) const
protected

Checks whether the connection is closed by the counterparty.

bool isConnectionClosed ( ) const
protected

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

Gateway& operator= ( const Gateway )
delete
Gateway& operator= ( Gateway &&  )
noexcept
SeqNumber outSeqNum ( ) const
noexcept
Returns
the sequence number of the next outgoing message.
Gateway& outSeqNum ( SeqNumber  nextOutSeqNum)
noexcept

Sets the sequence number of the next outgoing message.

int port ( ) const
noexcept
Returns
the listen port.
MessageBasePtr receive ( ) const
protected

Receives a message.

Establish4Ptr receiveEstablish ( )
protected

Receives the Establish4 message.

Exceptions
std::logic_errorif an unexpected type is received.
Negotiate1Ptr receiveNegotiate ( )
protected

Receives the Negotiate1 message.

Exceptions
std::logic_errorif an unexpected type is received.
Terminate7Ptr receiveTerminate ( )
protected

Receive the Terminate7 message.

Exceptions
std::logic_errorif an unexpected type is received.
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.

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.
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.
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.
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.
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.

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.

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.

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.

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.

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.

Sends the given message.

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

Sends the given data.

Gateway& sendSequence ( UInt32  nextSeqNo)

Sends the Sequence9 message.

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

Sends the Terminate7 message.

SessionID sessionId ( ) const
inlinenoexcept
Returns
session Id.

Definition at line 192 of file Gateway.h.

UInt64 sessionVerId ( ) const
inlinenoexcept
Returns
sessionVerId.

Definition at line 185 of file Gateway.h.

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

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

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.
int socketSendBufferSize ( ) const
noexcept
Returns
the size of the socket send buffer size.

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

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.
void swap ( Gateway )
noexcept

Swap with other.

Gateway& tcpNoDelayOption ( bool  noDelay)

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

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.

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

bool tryAcceptConnection ( const Timeout acceptTimeout = defaultTimeout())

Accepts an incoming connection.

If the operation is timed out, false is returned.

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.

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_
protected

sessionId.

Definition at line 333 of file Gateway.h.

UInt64 uId_ {0}
protected

sessionVerId.

Definition at line 330 of file Gateway.h.


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