OnixS C++ CME MDP Conflated TCP Handler 1.3.6
API Documentation
Loading...
Searching...
No Matches
Gateway Class Reference

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() [1/3]

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

◆ ~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 ( )

Accepts an incoming connection.

◆ acceptNegotiate()

Negotiate200Ptr acceptNegotiate ( UInt32 previousSeqNo = 0)
protected

Receives the Negotiate200 and responds with the NegotiationResponse202 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ acceptSession()

Gateway & acceptSession ( SeqNumber outgoingSequenceNumber = 1,
UInt64 previousUuid = 0,
UInt32 previousSeqNo = 0 )

Accepts an incoming Conflated TCP session.

◆ acceptTerminate()

Terminate203Ptr acceptTerminate ( )
protected

Receive the Terminate203 message and responds with the Terminate203 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ createNegotiationReject()

NegotiationReject201Container createNegotiationReject ( const Negotiate200Ptr & request,
ErrorCodes::Enum errorCodes,
const std::string & reason )
protected

Creates a NegotiationReject201 message.

◆ createNegotiationResponse()

NegotiationResponse202Container createNegotiationResponse ( const Negotiate200Ptr & request,
UInt32 previousSeqNo )
protected

Creates a NegotiationResponse202 message.

◆ createRequestAck()

template<typename TRequestMsg>
RequestAck206Container createRequestAck ( const TRequestMsg & request)
protected

Creates a RequestAck206 message.

Definition at line 266 of file Gateway.h.

◆ createRequestReject()

template<typename TRequestMsg>
RequestReject207Container createRequestReject ( const TRequestMsg & request)
protected

Creates a RequestReject207 message.

Definition at line 279 of file Gateway.h.

◆ createTerminate() [1/2]

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

Creates a Terminate203 message.

◆ createTerminate() [2/2]

Terminate203Container createTerminate ( const Terminate203Ptr & request)
protected

Creates a Terminate203 message.

◆ disconnect()

Gateway & disconnect ( )

Closes the accepted connection.

◆ enableLogger()

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

Enables logging.

◆ 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 std::chrono::seconds & 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
Returns
the sequence number of the next outgoing message.

◆ outSeqNum() [2/2]

Gateway & outSeqNum ( SeqNumber nextOutSeqNum)

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.

◆ receiveNegotiate()

Negotiate200Ptr receiveNegotiate ( )
protected

Receives the Negotiate200 message.

Exceptions
std::logic_errorif an unexpected type is received.

◆ receiveTerminate()

Terminate203Ptr receiveTerminate ( )
protected

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

◆ rejectNegotiate()

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.

◆ run()

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.

◆ send() [1/5]

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

Sends the given message.

Definition at line 307 of file Gateway.h.

◆ send() [2/5]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
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.

◆ send() [3/5]

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

Sends the given message.

Definition at line 297 of file Gateway.h.

◆ send() [4/5]

template<typename SbeMessageType, size_t MaxMessageSize, typename MessageInitializer>
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.

◆ send() [5/5]

Sends the given message.

◆ sendData()

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

Sends the given data.

◆ sendTerminate()

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

Sends the Terminate203 message.

◆ 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
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
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()

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

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

◆ uuid()

UInt64 uuid ( ) const
inlinenoexcept
Returns
UUUD.

Definition at line 142 of file Gateway.h.

◆ waitUntilTerminate()

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

◆ uId_

UInt64 uId_ {0}
protected

UUID.

Definition at line 251 of file Gateway.h.