OnixS C++ CME MDP Conflated TCP Handler  1.3.1
API Documentation
Gateway Class Reference

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

Public Member Functions

 Gateway (int port, const char *host="127.0.0.1", const std::chrono::seconds &timeout=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 ()
 
GatewayacceptSession (SeqNumber outgoingSequenceNumber=1, UInt64 previousUuid=0, UInt32 previousSeqNo=0)
 
Terminate203Ptr waitUntilTerminate (ClientMessageListener *listener=nullptr)
 
Gatewaydisconnect ()
 
int port () const noexcept
 
GatewayenableLogger (const std::string &logFileName)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, SeqNumber num)
 
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer >
Gatewaysend (ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, SeqNumber num)
 
template<typename TMsg >
MessagePtr< TMsg > receiveTypedMessage ()
 
Gatewayrun (ClientMessageListener &listener)
 
SeqNumber outSeqNum () const
 
GatewayoutSeqNum (SeqNumber nextOutSeqNum)
 
UInt64 uuid () const noexcept
 
GatewaytcpNoDelayOption (bool noDelay)
 
bool tcpNoDelayOption () const
 
int socketReceiveBufferSize () const
 
GatewaysocketReceiveBufferSize (int bufferSize)
 
int socketSendBufferSize () const
 
GatewaysocketSendBufferSize (int bufferSize)
 

Protected Member Functions

bool isConnectionClosed (const std::chrono::seconds &timeout) const
 
bool isConnectionClosed () const
 
MessageBasePtr receive () const
 
Negotiate200Ptr receiveNegotiate ()
 
Negotiate200Ptr acceptNegotiate (UInt32 previousSeqNo=0)
 
Negotiate200Ptr rejectNegotiate (ErrorCodes::Enum errorCodes=ErrorCodes::Enum(), const std::string &reason=std::string())
 
Terminate203Ptr receiveTerminate ()
 
Terminate203Ptr acceptTerminate ()
 
GatewaysendTerminate (const std::string &reason={}, ErrorCodes::Enum errCode=ErrorCodes::Other)
 
Terminate203Ptr terminate (const std::string &reason={}, ErrorCodes::Enum errCode=ErrorCodes::Other)
 
NegotiationResponse202Container createNegotiationResponse (const Negotiate200Ptr &request, UInt32 previousSeqNo)
 
NegotiationReject201Container createNegotiationReject (const Negotiate200Ptr &request, ErrorCodes::Enum errorCodes, const std::string &reason)
 
template<typename TRequestMsg >
RequestAck206Container createRequestAck (const TRequestMsg &request)
 
template<typename TRequestMsg >
RequestReject207Container createRequestReject (const TRequestMsg &request)
 
Terminate203Container createTerminate (const Terminate203Ptr &request)
 
Terminate203Container createTerminate (const std::string &reason, ErrorCodes::Enum errCode)
 
Gatewaysend (Messaging::SbeMessage, Messaging::SimpleOpenFramingHeader &)
 
GatewaysendData (const void *data, size_t size)
 

Protected Attributes

UInt64 uId_ {0}
 

Detailed Description

Definition at line 63 of file Gateway.h.

Constructor & Destructor Documentation

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

Deleted.

Gateway ( Gateway &&  )
noexcept

Move semantic.

Member Function Documentation

Gateway& acceptConnection ( )

Accepts an incoming connection.

Negotiate200Ptr acceptNegotiate ( UInt32  previousSeqNo = 0)
protected

Receives the Negotiate200 and responds with the NegotiationResponse202 message.

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

Accepts an incoming Conflated TCP session.

Terminate203Ptr acceptTerminate ( )
protected

Receive the Terminate203 message and responds with the Terminate203 message.

Exceptions
std::logic_errorif an unexpected type is received.
NegotiationReject201Container createNegotiationReject ( const Negotiate200Ptr request,
ErrorCodes::Enum  errorCodes,
const std::string &  reason 
)
protected

Creates a NegotiationReject201 message.

NegotiationResponse202Container createNegotiationResponse ( const Negotiate200Ptr request,
UInt32  previousSeqNo 
)
protected

Creates a NegotiationResponse202 message.

RequestAck206Container createRequestAck ( const TRequestMsg &  request)
protected

Creates a RequestAck206 message.

Definition at line 266 of file Gateway.h.

RequestReject207Container createRequestReject ( const TRequestMsg &  request)
protected

Creates a RequestReject207 message.

Definition at line 279 of file Gateway.h.

Terminate203Container createTerminate ( const Terminate203Ptr request)
protected

Creates a Terminate203 message.

Terminate203Container createTerminate ( const std::string &  reason,
ErrorCodes::Enum  errCode 
)
protected

Creates a Terminate203 message.

Gateway& disconnect ( )

Closes the accepted connection.

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

Enables logging.

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
Returns
the sequence number of the next outgoing message.
Gateway& outSeqNum ( SeqNumber  nextOutSeqNum)

Sets the sequence number of the next outgoing message.

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

Receives a message.

Negotiate200Ptr receiveNegotiate ( )
protected

Receives the Negotiate200 message.

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

Receive the Terminate203 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 291 of file Gateway.h.

Negotiate200Ptr rejectNegotiate ( ErrorCodes::Enum  errorCodes = ErrorCodes::Enum(),
const std::string &  reason = std::string() 
)
protected

Receives the Negotiate200 message and responds with the NegotiationReject201 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 & send ( ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &  msg)

Sends the given message.

Definition at line 297 of file Gateway.h.

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

Sends the given message.

Definition at line 307 of file Gateway.h.

Gateway & send ( ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &  msg,
SeqNumber  num 
)

Sets the given sequence number and send the message.

Definition at line 313 of file Gateway.h.

Gateway & send ( ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&  msg,
SeqNumber  num 
)

Sets the given sequence number and send the message.

Definition at line 320 of file Gateway.h.

Sends the given message.

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

Sends the given data.

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

Sends the Terminate203 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
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
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.

Terminate203Ptr terminate ( const std::string &  reason = {},
ErrorCodes::Enum  errCode = ErrorCodes::Other 
)
protected

Sends the Terminate203 meassage and waist until the response is received.

UInt64 uuid ( ) const
inlinenoexcept
Returns
UUUD.

Definition at line 142 of file Gateway.h.

Terminate203Ptr waitUntilTerminate ( ClientMessageListener *  listener = nullptr)

Waits until the Terminate203 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.

Member Data Documentation

UInt64 uId_ {0}
protected

UUID.

Definition at line 251 of file Gateway.h.


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