#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 | |
Gateway & | operator= (const Gateway &)=delete |
Gateway (Gateway &&) noexcept | |
Gateway & | operator= (Gateway &&) noexcept |
void | swap (Gateway &) noexcept |
Gateway & | acceptConnection (const Timeout &acceptTimeout=defaultTimeout()) |
bool | tryAcceptConnection (const Timeout &acceptTimeout=defaultTimeout()) |
Gateway & | acceptSession (SeqNumber outgoingSequenceNumber=1) |
Terminate7Ptr | waitUntilTerminate (ClientMessageListener *listener=nullptr, ClientSessionMessageListener *sessionMessageListener=nullptr, std::atomic< bool > *stopRequested=nullptr) |
Gateway & | sendSequence (UInt32 nextSeqNo) |
Gateway & | disconnect () |
const char * | host () const noexcept |
int | port () const noexcept |
Gateway & | enableLogger (const std::string &logFileName, unsigned int logLevel=3) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Gateway & | send (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Gateway & | send (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Gateway & | send (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, SeqNumber num) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Gateway & | send (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, SeqNumber num) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Gateway & | send (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, std::initializer_list< SeqNumber > numbers) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Gateway & | send (BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, std::initializer_list< SeqNumber > numbers) |
template<typename TMsg > | |
MessagePtr< TMsg > | receiveTypedMessage () |
Gateway & | run (ClientMessageListener &listener) |
Gateway & | run (ClientMessageListener &appMsgListener, ClientSessionMessageListener &sessionMsgListener) |
SeqNumber | outSeqNum () const noexcept |
Gateway & | outSeqNum (SeqNumber nextOutSeqNum) noexcept |
UInt64 | sessionVerId () const noexcept |
SessionID | sessionId () const noexcept |
Gateway & | tcpNoDelayOption (bool noDelay) |
bool | tcpNoDelayOption () const noexcept |
int | socketReceiveBufferSize () const |
Gateway & | socketReceiveBufferSize (int bufferSize) |
int | socketSendBufferSize () const noexcept |
Gateway & | socketSendBufferSize (int bufferSize) |
Static Protected Member Functions | |
static Timeout | defaultTimeout () |
Protected Attributes | |
UInt64 | uId_ {0} |
SessionID | sessionId_ |
Gateway | ( | const SessionSettings::LicenseStores & | licenseStores, |
int | port, | ||
const char * | host = "127.0.0.1" , |
||
const Timeout & | acceptTimeout = defaultTimeout() , |
||
const Timeout & | sendReceiveTimeout = defaultTimeout() |
||
) |
|
virtual |
Gateway& acceptConnection | ( | const Timeout & | acceptTimeout = defaultTimeout() | ) |
Accepts an incoming connection.
If the acceptTimeout
is zero, the acceptTimeout
provided in the constructor is used.
|
protected |
Receive the Establish4 message and respond with the EstablishAck5 message.
std::logic_error | if an unexpected type is received. |
|
protected |
Receives the Negotiate1 and responds with the NegotiateResponse2 message.
std::logic_error | if an unexpected type is received. |
|
protected |
Receive the Terminate7 message and responds with the Terminate7 message.
std::logic_error | if an unexpected type is received. |
|
protected |
Close the listening socket.
|
protected |
Creates a EstablishAck5 message.
|
protected |
Creates a EstablishReject6 message.
|
protected |
Creates a NegotiateReject3 message.
|
protected |
Creates a NegotiateResponse2 message.
|
protected |
Creates a Sequence9 message.
|
protected |
Creates a Terminate7 message.
|
protected |
Creates a Terminate7 message.
|
inlinestaticprotected |
Gateway& disconnect | ( | ) |
Closes the accepted connection.
Gateway& enableLogger | ( | const std::string & | logFileName, |
unsigned int | logLevel = 3 |
||
) |
Enables logging.
|
noexcept |
|
protected |
Checks whether the connection is closed by the counterparty.
|
protected |
Checks whether the connection is closed by the counterparty using the default timeout (provided in the constructor).
|
noexcept |
Sets the sequence number of the next outgoing message.
|
noexcept |
|
protected |
Receives a message.
|
protected |
Receives the Establish4 message.
std::logic_error | if an unexpected type is received. |
|
protected |
Receives the Negotiate1 message.
std::logic_error | if an unexpected type is received. |
|
protected |
Receive the Terminate7 message.
std::logic_error | if an unexpected type is received. |
MessagePtr< TMsg > receiveTypedMessage | ( | ) |
|
protected |
Receives the Establish4 message and responds with the EstablishReject6 message.
std::logic_error | if an unexpected type is received. |
|
protected |
Receives the Negotiate1 message and responds with the NegotiateReject3 message.
std::logic_error | if an unexpected type is received. |
Gateway& run | ( | ClientMessageListener & | listener | ) |
Accepts an incoming connection and establishes the session.
Gateway& run | ( | ClientMessageListener & | appMsgListener, |
ClientSessionMessageListener & | sessionMsgListener | ||
) |
Accepts an incoming connection and establishes the session.
Gateway & send | ( | BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & | msg | ) |
Gateway & send | ( | BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && | msg | ) |
Gateway & send | ( | BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & | msg, |
SeqNumber | num | ||
) |
Gateway & send | ( | BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && | msg, |
SeqNumber | num | ||
) |
Gateway & send | ( | BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & | msg, |
std::initializer_list< SeqNumber > | numbers | ||
) |
Gateway & send | ( | BOE::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && | msg, |
std::initializer_list< SeqNumber > | numbers | ||
) |
|
protected |
Sends the given message.
|
protected |
Sends the given data.
Gateway& sendSequence | ( | UInt32 | nextSeqNo | ) |
Sends the Sequence9 message.
|
protected |
Sends the Terminate7 message.
|
inlinenoexcept |
|
inlinenoexcept |
int socketReceiveBufferSize | ( | ) | const |
The default value is SessionSettings::Default::SocketReceiveBufferSize.
Gateway& socketReceiveBufferSize | ( | int | bufferSize | ) |
Sets the socket receive buffer size.
bufferSize | the size of the socket receive buffer size. If SessionSettings::UseOsDefaultSocketBufferSize then the default operating system value is used. |
|
noexcept |
The default value is SessionSettings::Default::SocketSedndBufferSize.
Gateway& socketSendBufferSize | ( | int | bufferSize | ) |
Sets the size of the socket send buffer size.
bufferSize | the size of the socket send buffer size. If SessionSettings::UseOsDefaultSocketBufferSize then the default operating system value is used. |
|
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).
|
noexcept |
TCP_NODELAY
socket option).The default value is SessionSettings::Default::TcpNoDelayOption.
|
protected |
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.
|
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.
outSeqNum
must be provided before invocation