OnixS C++ CME iLink 3 Binary Order Entry Handler  1.14.0
API Documentation
Gateway Class Reference

#include <OnixS/CME/iLink3/testing/Gateway.h>

Public Member Functions

 Gateway (int port, const char *host="127.0.0.1", const std::chrono::seconds &acceptTimeout=std::chrono::seconds(10), const std::chrono::seconds &sendReceiveTimeout=std::chrono::seconds(10))
 
virtual ~Gateway ()
 
 Gateway (const Gateway &)=delete
 
Gatewayoperator= (const Gateway &)=delete
 
 Gateway (Gateway &&) noexcept
 
Gatewayoperator= (Gateway &&) noexcept
 
void swap (Gateway &) noexcept
 
GatewayacceptConnection (const std::chrono::seconds &acceptTimeout=std::chrono::seconds(0))
 
GatewayacceptSession (SeqNumber outgoingSequenceNumber=1, UInt64 previousUuid=0, UInt32 previousSeqNo=0)
 
Terminate507Ptr waitUntilTerminate (ClientMessageListener *listener=nullptr, ClientSessionMessageListener *sessionMessageListener=nullptr)
 
GatewaysendSequence (UInt32 nextSeqNo, KeepAliveLapsed::Enum keepAliveLapsed=KeepAliveLapsed::NotLapsed, UInt64 uuid=0)
 
Gatewaydisconnect ()
 
const char * host () const noexcept
 
int port () const noexcept
 
GatewayenableLogger (const std::string &logFileName)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, SeqNumber num)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, SeqNumber num)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, std::initializer_list< SeqNumber > numbers)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (iLink3::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 uuid () const noexcept
 
FTI::Enum faultToleranceIndicator () const noexcept
 
GatewayfaultToleranceIndicator (FTI::Enum value)
 
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 std::chrono::seconds &timeout) const
 
bool isConnectionClosed () const
 
MessageBasePtr receive () const
 
Negotiate500Ptr receiveNegotiate ()
 
Negotiate500Ptr acceptNegotiate (UInt32 previousSeqNo=0)
 
Negotiate500Ptr rejectNegotiate (NegotiationRejectErrorCode::Enum errorCodes=NegotiationRejectErrorCode::Enum(), const std::string &reason=std::string())
 
Establish503Ptr receiveEstablish ()
 
Establish503Ptr acceptEstablish (UInt32 outgoingSequenceNumber=1, UInt64 previousUuid=0, UInt32 previousSeqNo=0)
 
Establish503Ptr rejectEstablish (UInt32 outgoingSequenceNumber=1, EstablishmentRejectErrorCode::Enum errorCodes=EstablishmentRejectErrorCode::Enum(), const std::string &reason=std::string())
 
Terminate507Ptr receiveTerminate ()
 
Terminate507Ptr acceptTerminate ()
 
GatewaysendTerminate (const std::string &reason={}, UInt16 errCode=TerminateErrorCode::Other)
 
Terminate507Ptr terminate (const std::string &reason={}, UInt16 errCode=TerminateErrorCode::Other)
 
NegotiationResponse501Container createNegotiationResponse (const Negotiate500Ptr &request, UInt32 previousSeqNo)
 
NegotiationReject502Container createNegotiationReject (const Negotiate500Ptr &request, NegotiationRejectErrorCode::Enum errorCodes, const std::string &reason)
 
EstablishmentAck504Container createEstablishmentAck (const Establish503Ptr &request, UInt32 outgoingSequenceNumber)
 
EstablishmentReject505Container createEstablishmentReject (const Establish503Ptr &request, UInt32 outgoingSequenceNumber, EstablishmentRejectErrorCode::Enum errorCodes, const std::string &reason)
 
Terminate507Container createTerminate (const Terminate507Ptr &request)
 
Terminate507Container createTerminate (const std::string &reason, UInt16 errCode)
 
Sequence506Container createSequence (UInt32 nextSeqNo, KeepAliveLapsed::Enum keepAliveLapsed=KeepAliveLapsed::NotLapsed, UInt64 uuid=0)
 
Gatewaysend (Messaging::SbeMessage, Messaging::SimpleOpenFramingHeader &)
 
GatewaysendData (const void *data, size_t size)
 
Gatewayclose ()
 

Protected Attributes

UInt64 uId_ {0}
 

Detailed Description

Definition at line 65 of file Gateway.h.

Constructor & Destructor Documentation

Gateway ( int  port,
const char *  host = "127.0.0.1",
const std::chrono::seconds &  acceptTimeout = std::chrono::seconds(10),
const std::chrono::seconds &  sendReceiveTimeout = std::chrono::seconds(10) 
)
explicit
virtual ~Gateway ( )
virtual
Gateway ( const Gateway )
delete

Deleted.

Gateway ( Gateway &&  )
noexcept

Move semantic.

Member Function Documentation

Gateway& acceptConnection ( const std::chrono::seconds &  acceptTimeout = std::chrono::seconds(0))

Accepts an incoming connection.

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

Establish503Ptr acceptEstablish ( UInt32  outgoingSequenceNumber = 1,
UInt64  previousUuid = 0,
UInt32  previousSeqNo = 0 
)
protected

Receive the Establish503 message and respond with the EstablishmentAck504 message.

Exceptions
std::logic_errorif an unexpected type is received.
Negotiate500Ptr acceptNegotiate ( UInt32  previousSeqNo = 0)
protected

Receives the Negotiate500 and responds with the NegotiationResponse501 message.

Exceptions
std::logic_errorif an unexpected type is received.
Gateway& acceptSession ( SeqNumber  outgoingSequenceNumber = 1,
UInt64  previousUuid = 0,
UInt32  previousSeqNo = 0 
)

Accepts an incoming iLink 3 session.

Terminate507Ptr acceptTerminate ( )
protected

Receive the Terminate507 message and responds with the Terminate507 message.

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

Close the listening socket.

EstablishmentAck504Container createEstablishmentAck ( const Establish503Ptr request,
UInt32  outgoingSequenceNumber 
)
protected

Creates a EstablishmentAck504 message.

EstablishmentReject505Container createEstablishmentReject ( const Establish503Ptr request,
UInt32  outgoingSequenceNumber,
EstablishmentRejectErrorCode::Enum  errorCodes,
const std::string &  reason 
)
protected

Creates a EstablishmentReject505 message.

NegotiationReject502Container createNegotiationReject ( const Negotiate500Ptr request,
NegotiationRejectErrorCode::Enum  errorCodes,
const std::string &  reason 
)
protected

Creates a NegotiationReject502 message.

NegotiationResponse501Container createNegotiationResponse ( const Negotiate500Ptr request,
UInt32  previousSeqNo 
)
protected

Creates a NegotiationResponse501 message.

Sequence506Container createSequence ( UInt32  nextSeqNo,
KeepAliveLapsed::Enum  keepAliveLapsed = KeepAliveLapsed::NotLapsed,
UInt64  uuid = 0 
)
protected

Creates a Sequence506 message.

Terminate507Container createTerminate ( const Terminate507Ptr request)
protected

Creates a Terminate507 message.

Terminate507Container createTerminate ( const std::string &  reason,
UInt16  errCode 
)
protected

Creates a Terminate507 message.

Gateway& disconnect ( )

Closes the accepted connection.

Gateway& enableLogger ( const std::string &  logFileName)

Enables logging.

FTI::Enum faultToleranceIndicator ( ) const
inlinenoexcept
Returns
the Fault Tolerance Indicator.

Definition at line 182 of file Gateway.h.

Gateway& faultToleranceIndicator ( FTI::Enum  value)
inline

Sets the Fault Tolerance Indicator.

Definition at line 188 of file Gateway.h.

const char* host ( ) const
noexcept
Returns
listen host.
bool isConnectionClosed ( const std::chrono::seconds &  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.

Establish503Ptr receiveEstablish ( )
protected

Receives the Establish503 message.

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

Receives the Negotiate500 message.

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

Receive the Terminate507 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 332 of file Gateway.h.

Establish503Ptr rejectEstablish ( UInt32  outgoingSequenceNumber = 1,
EstablishmentRejectErrorCode::Enum  errorCodes = EstablishmentRejectErrorCode::Enum(),
const std::string &  reason = std::string() 
)
protected

Receives the Establish503 message and responds with the EstablishmentReject505 message.

Exceptions
std::logic_errorif an unexpected type is received.
Negotiate500Ptr rejectNegotiate ( NegotiationRejectErrorCode::Enum  errorCodes = NegotiationRejectErrorCode::Enum(),
const std::string &  reason = std::string() 
)
protected

Receives the Negotiate500 message and responds with the NegotiationReject502 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.
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 ( iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &  msg)

Sends the given message.

Note
does not update outSeqNum.

Definition at line 338 of file Gateway.h.

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

Sends the given message.

Note
does not update outSeqNum.

Definition at line 348 of file Gateway.h.

Gateway & send ( iLink3::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 368 of file Gateway.h.

Gateway & send ( iLink3::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 375 of file Gateway.h.

Gateway & send ( iLink3::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 382 of file Gateway.h.

Gateway & send ( iLink3::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 394 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,
KeepAliveLapsed::Enum  keepAliveLapsed = KeepAliveLapsed::NotLapsed,
UInt64  uuid = 0 
)

Sends the Sequence506 message.

Gateway& sendTerminate ( const std::string &  reason = {},
UInt16  errCode = TerminateErrorCode::Other 
)
protected

Sends the Terminate507 message.

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.

Terminate507Ptr terminate ( const std::string &  reason = {},
UInt16  errCode = TerminateErrorCode::Other 
)
protected

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

UInt64 uuid ( ) const
inlinenoexcept
Returns
UUID.

Definition at line 175 of file Gateway.h.

Terminate507Ptr waitUntilTerminate ( ClientMessageListener listener = nullptr,
ClientSessionMessageListener sessionMessageListener = nullptr 
)

Waits until the Terminate507 message is received.

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

Note
actual outSeqNum must be provided before invocation

Member Data Documentation

UInt64 uId_ {0}
protected

UUID.

Definition at line 321 of file Gateway.h.


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