96 static constexpr uint64_t
POLL_NS = 1'000'000'000;
111 size_t on_data(
const uint8_t* data,
size_t size, uint64_t now_ns);
118 bool held() const noexcept {
return held_; }
127 const std::string&
version() const noexcept {
return version_; }
135 const std::vector<SimFeed>&
feeds() const noexcept {
return feeds_; }
144 bool take_changed() noexcept {
return std::exchange(changed_,
false); }
146 std::optional<ReplayAnswer>
take_replay_answer() {
return std::exchange(replay_answer_, std::nullopt); }
148 nlohmann::json
to_json()
const;
152 uint32_t request_id{0};
155 bool is(uint32_t
id)
const noexcept {
return request_id != 0 && request_id == id; }
156 bool expired(uint64_t now_ns)
const noexcept {
162 bool settled() const noexcept {
return listed_ && (!list_.pcap || watch_id_ != 0); }
164 bool status_fresh() const noexcept {
167 Pending send(uint8_t command, uint64_t now_ns);
168 void send_poll(uint64_t now_ns);
169 void on_poll(uint8_t command,
bool ok, std::string_view text, uint64_t now_ns);
170 void on_list(
bool ok, std::string_view text, uint64_t now_ns);
171 void on_status(std::string_view text);
172 void on_replay(
bool ok, std::string_view text, uint64_t now_ns);
174 ByteTransport& transport_;
175 uint32_t last_request_id_{0};
177 uint8_t poll_command_{0};
178 uint8_t last_command_{0};
179 uint32_t watch_id_{0};
180 bool can_watch_{
true};
182 Pending version_request_;
183 uint64_t next_poll_ns_{0};
184 uint64_t started_ns_{0};
185 bool starting_{
false};
186 bool connected_{
false};
189 bool changed_{
false};
190 bool last_ok_{
false};
191 std::string last_text_;
193 std::string version_;
195 std::vector<SimFeed> feeds_;
196 std::optional<ReplayAnswer> replay_answer_;