OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
PluggableStorage.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 37 of file PluggableStorage.cpp.

38{
39 // `--help` to show options.
41
42 try
43 {
45
46 auto settings = fillSettings(cfg);
47 const auto emulator = createEmulator(settings, cfg);
48
49 // Request Binary Order Gateway credentials from Binary Utility Service Gateway.
50 const auto bgwCredentials = receiveBgwCredentials(settings, cfg.host(), cfg.port());
51
52 MySessionStorage storage;
53 Listener listener;
54
55 // A 'BGW' session.
56 BgwSession bgwSession(settings, &listener, SessionStorageType::Pluggable, &storage);
57
58 bgwSession.connect(bgwCredentials);
59 bgwSession.send(Helper::createTraderLogonRequest(cfg.traderId(), cfg.traderPwd()));
60
61 Samples::wait(listener.traderLoggedOn).get();
62
63 bgwSession.send(Helper::createOrder(cfg.traderId()));
64
65 SignalHelper::waitUntilKey("disconnect the BGW session and terminate the application");
66
67 bgwSession.send(Helper::createTraderLogoutRequest(cfg.traderId())).disconnect();
68 }
69 catch (const std::exception& ex)
70 {
71 std::cerr << "EXCEPTION: " << ex.what() << std::endl;
72 return 1;
73 }
74
75 return 0;
76}
static MessageHolder< NewOrderRequest > createOrder(const std::string &traderId)
Definition Helpers.h:104
static MessageHolder< TraderLogoutRequest > createTraderLogoutRequest(const std::string &traderId)
Definition Helpers.h:95
static MessageHolder< TraderLogonRequest > createTraderLogonRequest(const std::string &traderId, const std::string &traderPwd)
Definition Helpers.h:77
std::promise< void > traderLoggedOn
Definition Listener.h:223
std::pair< std::unique_ptr< GatewayEmulatorThread< BusSessionGatewayListener > >, std::unique_ptr< GatewayEmulatorThread< GatewayListener > > > createEmulator(const SessionSettings &settings, const ConnectivityConfiguration &cfg, bool tcpDirect=false)
Definition Emulator.h:157
BgwCredentials receiveBgwCredentials(SessionSettings settings, std::string host, Port port)
Definition Listener.h:264
SessionSettings fillSettings(const LogonConfiguration &logonCfg, const ConnectivityConfiguration &connCfg, const SettingsConfiguration &settingsCfg)
Definition Settings.h:32
std::future< T > wait(Stack &stack, std::promise< T > &promise, std::chrono::seconds timeout=std::chrono::seconds{30})
Definition Listener.h:227
@ Pluggable
Pluggable Session Storage.
static void waitUntilKey(const std::string &message)
Definition Signal.h:57
static void manageSignals() noexcept
Definition Signal.h:46