25#if defined(ONIXS_ILINK3_HAS_GATEWAY_EMULATOR)
47 Message::blockLength(Message::Schema::Version)
49 + Message::getMinimalVariableFieldsSize(Message::Schema::Version);
71 using Timeout = std::chrono::milliseconds;
109 std::atomic<
bool>* stopRequested =
nullptr);
118 const
char *
host() const noexcept;
129 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
134 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
139 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
144 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
149 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
154 template <typename SbeMessageType,
size_t MaxMessageSize, typename MessageInitializer>
161 template <typename TMsg>
195 return faultToleranceIndicator_;
201 faultToleranceIndicator_ = value;
270 const std::
string & reason = std::
string());
308 const std::string & reason);
352template <
typename TMsg>
358template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
361 const auto messageSize = msg.
setHeader();
362 auto*
const header = msg.
header();
368template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
374template <
typename Holder>
375typename std::enable_if<std::is_base_of<TagBased::Message, typename Holder::MessageType>::value>::type
381template <
typename Holder>
382typename std::enable_if<!std::is_base_of<TagBased::Message, typename Holder::MessageType>::value>::type
388template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
395template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
402template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
406 for(
auto seqNum : numbers)
414template <
typename SbeMessageType,
size_t MaxMessageSize,
typename MessageInitializer>
418 for(
auto seqNum : numbers)
#define ONIXS_ILINK3_NODISCARD
#define ONIXS_ILINK3_EXPORTED
Contains the SimpleOpenFramingHeader, the SBE message, and the data buffer.
const SimpleOpenFramingHeader * header() const noexcept
MessageSize setHeader() noexcept
Calculates the binary size of the message and updates the Simple Open Framing Header accordingly.
std::vector< std::string > LicenseStores
Folders that contain license file(s).
Client's messages Listener.
Client's session messages Listener.
int socketReceiveBufferSize() const
int socketSendBufferSize() const noexcept
Gateway & send(iLink3::Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg)
Sends the given message.
Terminate507Ptr receiveTerminate()
Receive the Terminate507 message.
Gateway & acceptConnection(const Timeout &acceptTimeout=defaultTimeout())
Accepts an incoming connection.
Gateway(const SessionSettings::LicenseStores &licenseStores, int port, const char *host="127.0.0.1", const Timeout &acceptTimeout=defaultTimeout(), const Timeout &sendReceiveTimeout=defaultTimeout())
bool tryAcceptConnection(const Timeout &acceptTimeout=defaultTimeout())
Accepts an incoming connection.
Negotiate500Ptr acceptNegotiate(UInt32 previousSeqNo=0)
Receives the Negotiate500 and responds with the NegotiationResponse501 message.
MessageBasePtr receive() const
Receives a message.
Gateway(const Gateway &)=delete
Deleted.
Establish503Ptr receiveEstablish()
Receives the Establish503 message.
Sequence506Container createSequence(UInt32 nextSeqNo, KeepAliveLapsed::Enum keepAliveLapsed=KeepAliveLapsed::NotLapsed, UInt64 uuid=0)
Creates a Sequence506 message.
std::chrono::milliseconds Timeout
Timeout alias.
NegotiationReject502Container createNegotiationReject(const Negotiate500Ptr &request, NegotiationRejectErrorCode::Enum errorCodes, const std::string &reason)
Creates a NegotiationReject502 message.
Establish503Ptr rejectEstablish(UInt32 outgoingSequenceNumber=1, EstablishmentRejectErrorCode::Enum errorCodes=EstablishmentRejectErrorCode::Enum(), const std::string &reason=std::string())
Receives the Establish503 message and responds with the EstablishmentReject505 message.
Gateway & send(Messaging::SbeMessage, Messaging::SimpleOpenFramingHeader &)
Sends the given message.
int port() const noexcept
FTI::Enum faultToleranceIndicator() const noexcept
EstablishmentReject505Container createEstablishmentReject(const Establish503Ptr &request, UInt32 outgoingSequenceNumber, EstablishmentRejectErrorCode::Enum errorCodes, const std::string &reason)
Creates a EstablishmentReject505 message.
Gateway & acceptSession(SeqNumber outgoingSequenceNumber=1, UInt64 previousUuid=0, UInt32 previousSeqNo=0)
Accepts an incoming iLink 3 session.
NegotiationResponse501Container createNegotiationResponse(const Negotiate500Ptr &request, UInt32 previousSeqNo)
Creates a NegotiationResponse501 message.
Gateway & sendData(const void *data, size_t size)
Sends the given data.
SeqNumber outSeqNum() const noexcept
Terminate507Ptr terminate(const std::string &reason={}, UInt16 errCode=TerminateErrorCode::Other)
Sends the Terminate507 message and waits until the response is received.
Gateway & operator=(const Gateway &)=delete
Gateway & sendTerminate(const std::string &reason={}, UInt16 errCode=TerminateErrorCode::Other)
Sends the Terminate507 message.
Gateway & enableLogger(const std::string &logFileName, unsigned int logLevel=3)
Enables logging.
Negotiate500Ptr receiveNegotiate()
Receives the Negotiate500 message.
Gateway & close()
Close the listening socket.
Gateway & disconnect()
Closes the accepted connection.
Gateway(Gateway &&) noexcept
Move semantic.
Gateway & faultToleranceIndicator(FTI::Enum value)
Sets the Fault Tolerance Indicator.
bool tcpNoDelayOption() const noexcept
Negotiate500Ptr rejectNegotiate(NegotiationRejectErrorCode::Enum errorCodes=NegotiationRejectErrorCode::Enum(), const std::string &reason=std::string())
Receives the Negotiate500 message and responds with the NegotiationReject502 message.
Establish503Ptr acceptEstablish(UInt32 outgoingSequenceNumber=1, UInt64 previousUuid=0, UInt32 previousSeqNo=0)
Receive the Establish503 message and respond with the EstablishmentAck504 message.
Terminate507Container createTerminate(const Terminate507Ptr &request)
Creates a Terminate507 message.
EstablishmentAck504Container createEstablishmentAck(const Establish503Ptr &request, UInt32 outgoingSequenceNumber)
Creates a EstablishmentAck504 message.
Terminate507Container createTerminate(const std::string &reason, UInt16 errCode)
Creates a Terminate507 message.
Gateway & sendSequence(UInt32 nextSeqNo, KeepAliveLapsed::Enum keepAliveLapsed=KeepAliveLapsed::NotLapsed, UInt64 uuid=0)
Sends the Sequence506 message.
UInt64 uuid() const noexcept
Gateway & run(ClientMessageListener &listener)
Accepts an incoming connection and establishes the session.
static Timeout defaultTimeout()
Default timeout.
Terminate507Ptr waitUntilTerminate(ClientMessageListener *listener=nullptr, ClientSessionMessageListener *sessionMessageListener=nullptr, std::atomic< bool > *stopRequested=nullptr)
Waits until the Terminate507 message is received.
const char * host() const noexcept
bool isConnectionClosed(const Timeout &timeout) const
Checks whether the connection is closed by the counterparty.
MessagePtr< TMsg > receiveTypedMessage()
Receives the message of the particular type.
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...
MessageBasePtr tryReceive(const Timeout &timeout=defaultTimeout()) const
Receives a message using the provided timeout.
Terminate507Ptr acceptTerminate()
Receive the Terminate507 message and responds with the Terminate507 message.
std::enable_if< std::is_base_of< TagBased::Message, typenameHolder::MessageType >::value >::type setSeqNum(Holder &msg, SeqNumber num)
MessageHolder< Sequence506 > Sequence506Container
MessageHolder< Terminate507 > Terminate507Container
MessagePtr< Negotiate500 > Negotiate500Ptr
MessagePtr< Sequence506 > Sequence506Ptr
MessageHolder< NegotiationResponse501, calculateNegotiationResponse501MaxSize()> NegotiationResponse501Container
MessageHolder< EstablishmentAck504 > EstablishmentAck504Container
MessagePtr< Terminate507 > Terminate507Ptr
MessageHolder< EstablishmentReject505 > EstablishmentReject505Container
MessagePtr< Establish503 > Establish503Ptr
MessageHolder< NegotiationReject502 > NegotiationReject502Container
constexpr UInt16 calculateNegotiationResponse501MaxSize()
MessagePtr< AnotherType > cast(const MessagePtr< BaseType > &ptr)
Tries to cast to another type.
MessagePtr< SbeMessage > MessageBasePtr
Messaging::UInt32 SeqNumber
The Establishment Reject message error codes.
The Negotiation Reject message error codes.
@ Other
any other error condition not mentioned above