35 us_timer_t* heartbeat_timer_ =
nullptr;
37 std::atomic_bool running_{
false};
40 uint64_t response_read_index_ = 0;
42 using wsT = uWS::WebSocket<false, true, PerSocketData>;
46 std::unordered_map<std::string, wsT*> clients_;
49 int ping_interval_ms_{15000};
50 std::chrono::seconds pong_timeout_{60};
52 std::string products_;
53 std::unordered_map<std::string, std::string> product_by_id_;
58 double fee_rate_ = 0.0012;
65 std::string_view
type() const noexcept
override {
return "WS"; }
68 running_.store(
true, std::memory_order_release);
158 running_.store(
false, std::memory_order_release);
161 if (heartbeat_timer_) {
162 us_timer_close(heartbeat_timer_);
163 heartbeat_timer_ =
nullptr;
173 void setup_routes(uWS::App &app)
override;
175 void on_listen_socket(us_listen_socket_t *listen_socket)
override;
178 void handle_message(wsT *ws, std::string_view message);
181 void handle_close(wsT *ws,
int code, std::string_view message);
184 void send_error(wsT *ws,
const std::string& error_msg);
187 void schedule_response_processing() {
188 if (!running_.load(std::memory_order_acquire) || !
loop_) {
192 loop_->defer([
this]() {
193 process_all_responses();
199 void process_all_responses();
201 void handle_order_response(
const OrderResponse &response, wsT *ws);
204 void check_heartbeats();