24#if defined(ONIXS_CONFLATEDTCP_HAS_GATEWAY_EMULATOR)
28#include <OnixS/CME/ConflatedTCP/testing/ClientMessageListener.h>
44 Message::blockLength(Message::Schema::Version)
46 + Message::getMinimalVariableFieldsSize(Message::Schema::Version);
67 Gateway(
int port,
const char* host =
"127.0.0.1",
const std::chrono::seconds& timeout = std::chrono::seconds(10));
106 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
110 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
114 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
118 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
124 template <typename TMsg>
231 template <
typename TRequestMsg>
235 template <
typename TRequestMsg>
254 template<
typename MessageType>
255 void invokeCallback(
void(ClientMessageListener::*Callback)(
const MessageType &,
Gateway *), ClientMessageListener * listener,
const MessageBasePtr & msg)
265template <
typename TRequestMsg>
271 .setReqId(request->reqId())
272 .setSubscriptionReqType(request->subscriptionReqType())
278template <
typename TRequestMsg>
284 .setReqId(request->reqId())
290template <
typename TMsg>
296template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
299 const auto messageSize = msg.
setHeader();
300 auto*
const header = msg.
header();
306template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
312template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
319template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
#define ONIXS_CONFLATEDTCP_EXPORTED
#define ONIXS_CONFLATEDTCP_NODISCARD
Contains the SimpleOpenFramingHeader, the SBE message, and the data buffer.
MessageType & message() noexcept
const SimpleOpenFramingHeader * header() const noexcept
MessageSize setHeader() noexcept
Calculates the binary size of the message and updates the Simple Open Framing Header accordingly.
CME Conflated TCP Gateway Emulator.
int socketReceiveBufferSize() const
Negotiate200Ptr acceptNegotiate(UInt32 previousSeqNo=0)
Receives the Negotiate200 and responds with the NegotiationResponse202 message.
MessageBasePtr receive() const
Receives a message.
Gateway(const Gateway &)=delete
Deleted.
Terminate203Ptr terminate(const std::string &reason={}, ErrorCodes::Enum errCode=ErrorCodes::Other)
Sends the Terminate203 meassage and waist until the response is received.
int socketSendBufferSize() const
Gateway & send(Messaging::SbeMessage, Messaging::SimpleOpenFramingHeader &)
Sends the given message.
NegotiationResponse202Container createNegotiationResponse(const Negotiate200Ptr &request, UInt32 previousSeqNo)
Creates a NegotiationResponse202 message.
Gateway & socketReceiveBufferSize(int bufferSize)
Sets the socket receive buffer size.
Gateway & socketSendBufferSize(int bufferSize)
Sets the size of the socket send buffer size.
Terminate203Ptr acceptTerminate()
Receive the Terminate203 message and responds with the Terminate203 message.
int port() const noexcept
Negotiate200Ptr rejectNegotiate(ErrorCodes::Enum errorCodes=ErrorCodes::Enum(), const std::string &reason=std::string())
Receives the Negotiate200 message and responds with the NegotiationReject201 message.
RequestAck206Container createRequestAck(const TRequestMsg &request)
Creates a RequestAck206 message.
Gateway & acceptSession(SeqNumber outgoingSequenceNumber=1, UInt64 previousUuid=0, UInt32 previousSeqNo=0)
Accepts an incoming Conflated TCP session.
Gateway & sendData(const void *data, size_t size)
Sends the given data.
bool isConnectionClosed() const
Checks whether the connection is closed by the counterparty using the default timeout (provided in th...
Gateway & operator=(const Gateway &)=delete
Gateway & disconnect()
Closes the accepted connection.
Gateway(Gateway &&) noexcept
Move semantic.
Gateway & sendTerminate(const std::string &reason={}, ErrorCodes::Enum errCode=ErrorCodes::Other)
Sends the Terminate203 message.
NegotiationReject201Container createNegotiationReject(const Negotiate200Ptr &request, ErrorCodes::Enum errorCodes, const std::string &reason)
Creates a NegotiationReject201 message.
Gateway & acceptConnection()
Accepts an incoming connection.
UInt64 uuid() const noexcept
Gateway & run(ClientMessageListener &listener)
Accepts an incoming connection and establishes the session.
Terminate203Container createTerminate(const std::string &reason, ErrorCodes::Enum errCode)
Creates a Terminate203 message.
Gateway & send(ConflatedTCP::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg)
Sends the given message.
SeqNumber outSeqNum() const
bool isConnectionClosed(const std::chrono::seconds &timeout) const
Checks whether the connection is closed by the counterparty.
Negotiate200Ptr receiveNegotiate()
Receives the Negotiate200 message.
Gateway & enableLogger(const std::string &logFileName)
Enables logging.
Gateway(int port, const char *host="127.0.0.1", const std::chrono::seconds &timeout=std::chrono::seconds(10))
MessagePtr< TMsg > receiveTypedMessage()
Receives the message of the particular type.
Terminate203Ptr waitUntilTerminate(ClientMessageListener *listener=nullptr)
Waits until the Terminate203 message is received.
void swap(Gateway &) noexcept
Swap with other.
Terminate203Ptr receiveTerminate()
Receive the Terminate203 message.
RequestReject207Container createRequestReject(const TRequestMsg &request)
Creates a RequestReject207 message.
bool tcpNoDelayOption() const
Gateway & tcpNoDelayOption(bool noDelay)
Sets the value of the option to improve latency at the expense of message throughput (the TCP_NODELAY...
Terminate203Container createTerminate(const Terminate203Ptr &request)
Creates a Terminate203 message.
MessageHolder< RequestAck206 > RequestAck206Container
MessageHolder< NegotiationResponse202, calculateNegotiationResponse202MaxSize()> NegotiationResponse202Container
MessagePtr< Negotiate200 > Negotiate200Ptr
MessageHolder< NegotiationReject201 > NegotiationReject201Container
MessagePtr< RequestAck206 > RequestAck206Ptr
MessageHolder< RequestReject207 > RequestReject207Container
MessagePtr< RequestReject207 > RequestReject207Ptr
MessageHolder< Terminate203 > Terminate203Container
MessagePtr< Terminate203 > Terminate203Ptr
MessagePtr< AnotherType > cast(const MessagePtr< BaseType > &ptr)
Tries to cast to another type.
MessagePtr< SbeMessage > MessageBasePtr
constexpr UInt16 calculateNegotiationResponse202MaxSize()
Messaging::UInt32 SeqNumber
@ Other
Unexpected request, see Reason field for details.
@ FullAck
Requested subscription scope is fully acknowledged .