50 auto report = gateway->createIpReport(request.
users()[0].userId(),
toStrRef(host_), port_,
toStrRef(
"emulator_token"));
52 gateway->send(report, gateway->outSeqNum());
56 const std::string host_{};
60class GatewayListener final :
public ONIXS_ICEBOE_NAMESPACE::Testing::ClientMessageListener
67 gateway->send(
report_, gateway->outSeqNum());
83 .orderStatus(OrderStatusEnum::Fill)
85 .memo(
"HelloFromEmulator")
92template <
class Listener>
97 : gateway_(licenseStores, port, host.c_str(), std::chrono::seconds{10}, std::chrono::seconds{10})
98 , clientMessageListener_(std::move(clientMessageListener))
100 std::promise<void> emulatorTaskPromise;
101 emulatorTaskDone_ = emulatorTaskPromise.get_future();
105 [&](std::promise<void>& p)
109 gateway_.run(*clientMessageListener_, &stopRequested_);
112 catch (
const std::exception& ex)
114 std::cerr <<
"Exception in Emulator's thread: " << ex.what() <<
'.' << std::endl;
115 p.set_exception(std::current_exception());
119 std::cerr <<
"UNKNOWN Exception in Emulator's thread." << std::endl;
120 p.set_exception(std::current_exception());
123 std::move(emulatorTaskPromise)))
129 stopRequested_.store(
true);
131 if(emulatorTaskDone_.valid())
132 emulatorTaskDone_.wait_for(std::chrono::seconds(10));
135 void wait(std::chrono::seconds timeout = std::chrono::seconds(10))
137 if(emulatorTaskDone_.valid())
139 std::future<void> f = std::move(emulatorTaskDone_);
151 std::atomic<bool> stopRequested_ {
false};
152 Testing::Gateway gateway_;
153 std::unique_ptr<Listener> clientMessageListener_;
154 std::future<void> emulatorTaskDone_;
165 throw std::runtime_error(
"Emulator is not supported for TCPDirect.");
168 std::clog <<
"!Emulator is used!" << std::endl;
176 return std::make_pair(std::move(busSessionEmulatorThread), std::move(bgwSessionEmulatorThread));
#define ONIXS_ICEBOE_NAMESPACE
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE
Contains the SimpleOpenFramingHeader, the SBE message, and the data buffer.
bool empty() const noexcept
const LicenseStores & licenseStores() const noexcept
BusSessionGatewayListener(const std::string &host, Port port)
void onIPRequest(const IPRequest request, OnixS::ICE::BOE::Testing::Gateway *gateway) override
Called when a IPRequest message is received.
GatewayEmulatorThread(const SessionSettings::LicenseStores &licenseStores, const std::string &host, Port port, std::unique_ptr< Listener > clientMessageListener)
void wait(std::chrono::seconds timeout=std::chrono::seconds(10))
const Testing::Gateway & gateway() const noexcept
void updateReport(const NewOrderRequest &order)
void onNewOrderRequest(const NewOrderRequest order, OnixS::ICE::BOE::Testing::Gateway *gateway) override
Called when a NewOrderRequest message is received.
MessageHolder< ExecutionReport_New > report_
std::vector< std::string > LicenseStores
Folders that contain license file(s).
StrRef toStrRef(const std::string &str)
Constructs a StrRef instance over th std::string content.
std::pair< std::unique_ptr< GatewayEmulatorThread< BusSessionGatewayListener > >, std::unique_ptr< GatewayEmulatorThread< GatewayListener > > > createEmulator(const SessionSettings &settings, const ConnectivityConfiguration &cfg, bool tcpDirect=false)
std::unique_ptr< T > makeUnique(Args &&...args)
Request IP Address, Port, and Session Tokens for Binary Order Gateways.
Users users() const noexcept
auto clOrdId() const noexcept
Provides access to clOrdID field.
auto side() const noexcept
Provides access to side field.
auto originatorUserId() const noexcept
Provides access to originatorUserID field.
auto symbol() const noexcept
Provides access to symbol field.
auto ordType() const noexcept
Provides access to ordType field.