Route cellular perception to its owner
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (postgres) (push) Failing after 53s
Foundation / checks (tsan) (push) Failing after 34s
Foundation / checks (network) (push) Failing after 3m0s
Foundation / checks (client) (push) Failing after 4m27s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (postgres) (push) Failing after 53s
Foundation / checks (tsan) (push) Failing after 34s
Foundation / checks (network) (push) Failing after 3m0s
Foundation / checks (client) (push) Failing after 4m27s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -27,6 +27,7 @@ struct RegionSessionClient::Impl {
|
||||
std::vector<network::PrimitiveLifeReceipt> primitive_life_receipts;
|
||||
std::vector<network::PrimitiveLifeOutcome> primitive_life_outcomes;
|
||||
std::optional<network::SnapshotAssembler> snapshots;
|
||||
std::optional<network::CellularPerception> cellular_perception;
|
||||
std::uint64_t snapshot_chunks{}, snapshot_bytes{};
|
||||
std::optional<network::HandoffOffer> handoff; // v4: continue at another region.
|
||||
std::optional<network::RegionAddress> redirect; // v4: the probe is owned elsewhere.
|
||||
@@ -129,6 +130,11 @@ struct RegionSessionClient::Impl {
|
||||
}
|
||||
if (const auto* m = std::get_if<network::ActionOutcome>(&*decoded))
|
||||
return keep(action_outcomes, *m);
|
||||
if (const auto* m = std::get_if<network::CellularPerception>(&*decoded)) {
|
||||
seen_tick(m->tick);
|
||||
cellular_perception = *m;
|
||||
return;
|
||||
}
|
||||
if (const auto* m = std::get_if<network::PrimitiveLifeReceipt>(&*decoded)) {
|
||||
seen_tick(m->server_tick);
|
||||
return keep(primitive_life_receipts, *m);
|
||||
@@ -152,7 +158,8 @@ RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point
|
||||
if (config.protocol_version != network::session_protocol_version &&
|
||||
config.protocol_version != network::session_protocol_v5 &&
|
||||
config.protocol_version != network::session_protocol_v6 &&
|
||||
config.protocol_version != network::session_protocol_v7)
|
||||
config.protocol_version != network::session_protocol_v7 &&
|
||||
config.protocol_version != network::session_protocol_v8)
|
||||
return std::unexpected(network::quic::EndpointError::configuration);
|
||||
auto endpoint = network::quic::Endpoint::connect(config.transport);
|
||||
if (!endpoint)
|
||||
@@ -257,7 +264,8 @@ bool RegionSessionClient::send_cellular_action(
|
||||
std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x, std::int16_t move_y,
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target) {
|
||||
auto& m = *impl_;
|
||||
return m.protocol_version == network::session_protocol_v7 &&
|
||||
return (m.protocol_version == network::session_protocol_v7 ||
|
||||
m.protocol_version == network::session_protocol_v8) &&
|
||||
m.state == RegionSessionState::established && m.welcome && action_id != 0 && tick != 0 &&
|
||||
m.send(network::CellularAction{m.welcome->session, m.welcome->epoch, action_id, tick,
|
||||
move_x, move_y, intake_target.has_value(),
|
||||
@@ -268,20 +276,23 @@ bool RegionSessionClient::send_cellular_action(
|
||||
bool RegionSessionClient::query_action(std::uint64_t action_id) {
|
||||
auto& m = *impl_;
|
||||
return (m.protocol_version == network::session_protocol_version ||
|
||||
m.protocol_version == network::session_protocol_v7) &&
|
||||
m.protocol_version == network::session_protocol_v7 ||
|
||||
m.protocol_version == network::session_protocol_v8) &&
|
||||
m.state == RegionSessionState::established && m.send(network::ActionQuery{action_id});
|
||||
}
|
||||
|
||||
bool RegionSessionClient::request_primitive_life(std::uint64_t request_id) {
|
||||
auto& m = *impl_;
|
||||
return m.protocol_version == network::session_protocol_v5 &&
|
||||
return (m.protocol_version == network::session_protocol_v5 ||
|
||||
m.protocol_version == network::session_protocol_v8) &&
|
||||
m.state == RegionSessionState::established && m.welcome && request_id != 0 &&
|
||||
m.send(network::PrimitiveLifeRequest{m.welcome->session, m.welcome->epoch, request_id});
|
||||
}
|
||||
|
||||
bool RegionSessionClient::query_primitive_life(std::uint64_t request_id) {
|
||||
auto& m = *impl_;
|
||||
return m.protocol_version == network::session_protocol_v5 &&
|
||||
return (m.protocol_version == network::session_protocol_v5 ||
|
||||
m.protocol_version == network::session_protocol_v8) &&
|
||||
m.state == RegionSessionState::established && request_id != 0 &&
|
||||
m.send(network::PrimitiveLifeQuery{request_id});
|
||||
}
|
||||
@@ -317,7 +328,8 @@ std::uint64_t RegionSessionClient::server_tick() const noexcept {
|
||||
bool RegionSessionClient::set_interest(const network::SessionInterest& interest) {
|
||||
auto& m = *impl_;
|
||||
return (m.protocol_version == network::session_protocol_version ||
|
||||
m.protocol_version == network::session_protocol_v7) &&
|
||||
m.protocol_version == network::session_protocol_v7 ||
|
||||
m.protocol_version == network::session_protocol_v8) &&
|
||||
m.state == RegionSessionState::established && m.send(interest);
|
||||
}
|
||||
|
||||
@@ -326,6 +338,11 @@ const network::ReplicatedView* RegionSessionClient::view() const noexcept {
|
||||
return snapshots ? snapshots->latest() : nullptr;
|
||||
}
|
||||
|
||||
const std::optional<network::CellularPerception>&
|
||||
RegionSessionClient::cellular_perception() const noexcept {
|
||||
return impl_->cellular_perception;
|
||||
}
|
||||
|
||||
std::expected<client::EnvironmentPresentation, client::ViewError>
|
||||
RegionSessionClient::environment() const {
|
||||
const auto& snapshots = impl_->snapshots;
|
||||
|
||||
@@ -398,7 +398,8 @@ struct RegionSessions::Impl {
|
||||
!((config.accept_cellular_intentions &&
|
||||
c.protocol_version == network::session_protocol_v6) ||
|
||||
(config.accept_cellular_actions &&
|
||||
c.protocol_version == network::session_protocol_v7))))
|
||||
(c.protocol_version == network::session_protocol_v7 ||
|
||||
c.protocol_version == network::session_protocol_v8)))))
|
||||
return close(c, SessionCloseReason::protocol, now);
|
||||
if (const auto* ack = std::get_if<network::SnapshotAck>(&*decoded))
|
||||
return replication.acknowledge(c.session, *ack);
|
||||
@@ -560,12 +561,13 @@ struct RegionSessions::Impl {
|
||||
c.protocol_version = wire_version;
|
||||
const bool primitive_v5 = static_cast<bool>(config.create_primitive_life);
|
||||
const bool cellular_v6 = config.accept_cellular_intentions;
|
||||
const bool cellular_v7 = config.accept_cellular_actions;
|
||||
const bool cellular_actions = config.accept_cellular_actions;
|
||||
if ((primitive_v5 && wire_version < network::session_protocol_v5) ||
|
||||
(wire_version == network::session_protocol_v5 && !primitive_v5) ||
|
||||
(wire_version == network::session_protocol_v6 && !cellular_v6) ||
|
||||
(wire_version == network::session_protocol_v7 && !cellular_v7) ||
|
||||
wire_version > network::session_protocol_v7)
|
||||
((wire_version == network::session_protocol_v7 ||
|
||||
wire_version == network::session_protocol_v8) && !cellular_actions) ||
|
||||
wire_version > network::session_protocol_v8)
|
||||
return close(c, SessionCloseReason::unsupported_version, now);
|
||||
} else if (wire_version != c.protocol_version) {
|
||||
return close(c, SessionCloseReason::unsupported_version, now);
|
||||
@@ -588,7 +590,8 @@ struct RegionSessions::Impl {
|
||||
return;
|
||||
}
|
||||
if (const auto* m = std::get_if<network::CellularAction>(&*decoded)) {
|
||||
if (c.protocol_version != network::session_protocol_v7)
|
||||
if (c.protocol_version != network::session_protocol_v7 &&
|
||||
c.protocol_version != network::session_protocol_v8)
|
||||
return close(c, SessionCloseReason::protocol, now);
|
||||
if (const auto receipt = intents.admit(c.session, *m, admission()))
|
||||
answer(c, *receipt);
|
||||
@@ -835,6 +838,31 @@ void RegionSessions::replicate(
|
||||
m.send_datagram(*c, chunk); // A refused chunk leaves the snapshot unacknowledged.
|
||||
}
|
||||
|
||||
bool RegionSessions::send_cellular_perception(
|
||||
const network::AccountId& account, const network::CellularPerception& perception) {
|
||||
auto& m = *impl_;
|
||||
for (const auto& c : m.connections) {
|
||||
if (c.state != Impl::State::established || c.protocol_version != network::session_protocol_v8 ||
|
||||
c.account_id != account)
|
||||
continue;
|
||||
return m.endpoint
|
||||
->send_message(c.id, network::encode_session(perception, c.protocol_version))
|
||||
.has_value();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RegionSessions::clear_cellular_perceptions(std::uint64_t tick) {
|
||||
if (tick == 0)
|
||||
return;
|
||||
auto& m = *impl_;
|
||||
const network::CellularPerception cleared{tick, 0, {}};
|
||||
for (const auto& c : m.connections)
|
||||
if (c.state == Impl::State::established &&
|
||||
c.protocol_version == network::session_protocol_v8)
|
||||
m.send(c, cleared);
|
||||
}
|
||||
|
||||
network::ReplicationStats RegionSessions::replication_stats() const {
|
||||
return impl_->replication.stats();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user