Re-arrange some methods in ILinkGW.h
This commit is contained in:
1 parent
06b955dceb
commit
8c3da4e43c
2 files changed
+31
-16
No files matched your search
@@ -57,6 +57,7 @@ enum class State {
|
||||
typedef std::function<void(State)> OnStateChange;
|
||||
typedef std::function<void(const ExecutionReport*)> OnExecutionReport;
|
||||
typedef std::function<void(const Session& s)> OnSessionChange;
|
||||
typedef std::function<void(OrderKey,std::string)> OnCancelReject;
|
||||
|
||||
// Does not allow re-entrance
|
||||
class ILinkGW : IL3ConnectionHandler {
|
||||
@@ -78,28 +79,33 @@ public:
|
||||
ILinkGW(IL3Connection&, const Session&, const Config&);
|
||||
|
||||
void connect();
|
||||
void send_order(const CreateOrderMsg&);
|
||||
void send_cancel_replace(const CancelReplaceOrderMsg&);
|
||||
void send_cancel(const CancelOrderMsg&);
|
||||
void send_terminate(uint16_t code=0);
|
||||
void flush();
|
||||
void on_time() {};
|
||||
|
||||
// state change
|
||||
State state() { return _x_state; }
|
||||
void subscribe_state(OnStateChange o) { _on_state_change = o; }
|
||||
// Just
|
||||
void subscribe_execution_reports(OnExecutionReport sub) {
|
||||
_on_exe_report = sub;
|
||||
_on_replay_exe_report = sub;
|
||||
}
|
||||
void subscribe_session(OnSessionChange cb) { _on_session_change = cb; }
|
||||
void subscribe_cancel_reject(OnCancelReject) {}
|
||||
|
||||
public:
|
||||
void send_negotiate();
|
||||
void send_establish();
|
||||
void send_heartbeat();
|
||||
void send_sequence(bool lapsed=false);
|
||||
void send_retransmit_request(uint64_t uuid, uint32_t from, size_t count = 0);
|
||||
uint64_t send_party_details(const api::orderman::RoutingRecord&);
|
||||
void send_order(const CreateOrderMsg&);
|
||||
void send_cancel_replace(const CancelReplaceOrderMsg&);
|
||||
void send_cancel(const CancelOrderMsg&);
|
||||
void send_terminate(uint16_t code=0);
|
||||
void flush();
|
||||
|
||||
// state change
|
||||
State state() { return _x_state; }
|
||||
void subscribe_state(OnStateChange o) { _on_state_change = o; }
|
||||
void subscribe_execution_reports(OnExecutionReport sub, OnExecutionReport rsub) {
|
||||
_on_exe_report = sub;
|
||||
_on_replay_exe_report = rsub;
|
||||
}
|
||||
void subscribe_session(OnSessionChange cb) { _on_session_change = cb; }
|
||||
|
||||
private: // Functions
|
||||
private:
|
||||
void set_state(State);
|
||||
uint32_t next_seq() { return ++_session.to_cme; }
|
||||
void publish_session_update() { _on_session_change(_session); }
|
||||
|
||||
@@ -118,6 +118,7 @@ struct TestRunner {
|
||||
}
|
||||
|
||||
void send_order(api::Security& security) {
|
||||
bts_assert(gw.state() == State::READY);
|
||||
using namespace orderman;
|
||||
api::orderman::RoutingRecord r;
|
||||
r.set_account("CustAccount");
|
||||
@@ -149,7 +150,11 @@ struct TestRunner {
|
||||
using namespace orderman;
|
||||
const ExecutionReport* last_report;
|
||||
gw.subscribe_execution_reports([&](const ExecutionReport* r) { last_report = r; }, [](auto*) {});
|
||||
run(3);
|
||||
run_until([&]() { return gw.state() == State::READY; });
|
||||
if (gw.state() != State::READY) {
|
||||
std::cout << "Error?";
|
||||
return;
|
||||
}
|
||||
|
||||
// send a market order
|
||||
auto sec = securities();
|
||||
@@ -168,6 +173,10 @@ struct TestRunner {
|
||||
}
|
||||
|
||||
// send a cancel
|
||||
if (last_report) {
|
||||
// gw.send_cancel(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user