Define cellular intention session protocol v6
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m54s
Foundation / checks (client) (push) Failing after 4m23s
Foundation / checks (network) (push) Failing after 3m5s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 11s
Foundation / checks (postgres) (push) Canceled after 57s
Foundation / checks (checks) (push) Canceled after 5m23s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m54s
Foundation / checks (client) (push) Failing after 4m23s
Foundation / checks (network) (push) Failing after 3m5s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 11s
Foundation / checks (postgres) (push) Canceled after 57s
Foundation / checks (checks) (push) Canceled after 5m23s
This commit is contained in:
@@ -11,6 +11,7 @@ constexpr std::size_t refresh_bytes = session_grant_wire_bytes;
|
||||
constexpr std::size_t refresh_result_bytes = 1 + 8;
|
||||
constexpr std::size_t close_bytes = 1;
|
||||
constexpr std::size_t intention_bytes = (std::size_t{4} * 8) + 4;
|
||||
constexpr std::size_t cellular_intention_bytes = (std::size_t{4} * 8) + 4 + 1 + 3 + 8;
|
||||
constexpr std::size_t intention_receipt_bytes = 8 + 1 + 8;
|
||||
constexpr std::size_t simulated_bytes = std::size_t{3} * 8;
|
||||
constexpr std::size_t action_bytes = (std::size_t{3} * 8) + 2 + 8;
|
||||
@@ -102,11 +103,15 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message) {
|
||||
std::holds_alternative<PrimitiveLifeReceipt>(message) ||
|
||||
std::holds_alternative<PrimitiveLifeOutcome>(message) ||
|
||||
std::holds_alternative<PrimitiveLifeQuery>(message);
|
||||
return encode_session(message, is_life ? session_protocol_v5 : session_protocol_version);
|
||||
const auto version = std::holds_alternative<CellularIntention>(message) ? session_protocol_v6
|
||||
: is_life ? session_protocol_v5
|
||||
: session_protocol_version;
|
||||
return encode_session(message, version);
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uint16_t version) {
|
||||
if (version != session_protocol_version && version != session_protocol_v5)
|
||||
if (version != session_protocol_version && version != session_protocol_v5 &&
|
||||
version != session_protocol_v6)
|
||||
return {};
|
||||
if (version == session_protocol_version &&
|
||||
(std::holds_alternative<PrimitiveLifeRequest>(message) ||
|
||||
@@ -114,6 +119,8 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
|
||||
std::holds_alternative<PrimitiveLifeOutcome>(message) ||
|
||||
std::holds_alternative<PrimitiveLifeQuery>(message)))
|
||||
return {};
|
||||
if (version != session_protocol_v6 && std::holds_alternative<CellularIntention>(message))
|
||||
return {};
|
||||
struct Encoder {
|
||||
std::uint16_t version;
|
||||
std::vector<std::uint8_t> operator()(const SessionHello& m) const {
|
||||
@@ -153,6 +160,19 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
|
||||
put(out, static_cast<std::uint16_t>(m.move_y), 2);
|
||||
return out;
|
||||
}
|
||||
std::vector<std::uint8_t> operator()(const CellularIntention& m) const {
|
||||
auto out =
|
||||
header(SessionMessageType::cellular_intention, cellular_intention_bytes, version);
|
||||
for (const auto v : {m.session, m.epoch, m.sequence, m.tick})
|
||||
put(out, v, 8);
|
||||
put(out, static_cast<std::uint16_t>(m.move_x), 2);
|
||||
put(out, static_cast<std::uint16_t>(m.move_y), 2);
|
||||
out.push_back(m.has_intake_target ? 1 : 0);
|
||||
put(out, 0, 3);
|
||||
put(out, m.intake_x_um, 4);
|
||||
put(out, m.intake_y_um, 4);
|
||||
return out;
|
||||
}
|
||||
std::vector<std::uint8_t> operator()(const IntentionReceipt& m) const {
|
||||
auto out =
|
||||
header(SessionMessageType::intention_receipt, intention_receipt_bytes, version);
|
||||
@@ -283,7 +303,8 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
|
||||
if (get(bytes, 0, 4) != session_magic)
|
||||
return std::unexpected(SessionCodecError::bad_magic);
|
||||
const auto wire_version = static_cast<std::uint16_t>(get(bytes, 4, 2));
|
||||
if (wire_version != session_protocol_version && wire_version != session_protocol_v5)
|
||||
if (wire_version != session_protocol_version && wire_version != session_protocol_v5 &&
|
||||
wire_version != session_protocol_v6)
|
||||
return std::unexpected(SessionCodecError::unsupported_version);
|
||||
if (version)
|
||||
*version = wire_version;
|
||||
@@ -344,6 +365,27 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
|
||||
m.move_y = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(payload, 34, 2)));
|
||||
return m; // Ranges belong to admission, which answers with a status.
|
||||
}
|
||||
case static_cast<std::uint8_t>(SessionMessageType::cellular_intention): {
|
||||
if (wire_version < session_protocol_v6)
|
||||
return std::unexpected(SessionCodecError::unsupported_version);
|
||||
if (!expect(cellular_intention_bytes))
|
||||
return std::unexpected(SessionCodecError::wrong_length);
|
||||
CellularIntention m;
|
||||
m.session = get(payload, 0, 8);
|
||||
m.epoch = get(payload, 8, 8);
|
||||
m.sequence = get(payload, 16, 8);
|
||||
m.tick = get(payload, 24, 8);
|
||||
m.move_x = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(payload, 32, 2)));
|
||||
m.move_y = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(payload, 34, 2)));
|
||||
if (payload[36] > 1 || payload[37] != 0 || payload[38] != 0 || payload[39] != 0)
|
||||
return std::unexpected(SessionCodecError::invalid_value);
|
||||
m.has_intake_target = payload[36] != 0;
|
||||
m.intake_x_um = static_cast<std::uint32_t>(get(payload, 40, 4));
|
||||
m.intake_y_um = static_cast<std::uint32_t>(get(payload, 44, 4));
|
||||
if (!m.has_intake_target && (m.intake_x_um != 0 || m.intake_y_um != 0))
|
||||
return std::unexpected(SessionCodecError::invalid_value);
|
||||
return m;
|
||||
}
|
||||
case static_cast<std::uint8_t>(SessionMessageType::intention_receipt): {
|
||||
if (!expect(intention_receipt_bytes))
|
||||
return std::unexpected(SessionCodecError::wrong_length);
|
||||
|
||||
Reference in New Issue
Block a user