feat(simulation): demux inbound bridge stream — receive() + atlas routing (#969, D-225)
Replaces the fixed-type SimBridge::receive_inputs() with a tagged receive() -> Option<Inbound>, where Inbound is Inputs(Vec<PlayerInput>) or AtlasRequest(AtlasLayerRequest). A shared decode_inbound() demuxes a frame by shape (msgpack array = inputs, map = atlas request) — additive, no wire change to existing input/snapshot frames. Adds send_atlas_response() to the trait (both TcpBridge + LocalBridge impls). receive_bridge_inputs routes inputs to the InputQueue as before; atlas requests to a new AtlasRequestBuffer (drained by the serve system next). Integration tests (bridge_tcp/bridge_ipc) updated to the tagged receive(); a demux unit test covers all three branches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use settled_reach_server::bridge::framing::{read_framed, write_framed};
|
||||
use settled_reach_server::bridge::local::LocalBridge;
|
||||
use settled_reach_server::bridge::types::*;
|
||||
use settled_reach_server::bridge::SimBridge;
|
||||
use settled_reach_server::bridge::{Inbound, SimBridge};
|
||||
use settled_reach_server::simulation::time::{DayPhase, TickRate};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::path::PathBuf;
|
||||
@@ -116,7 +116,10 @@ fn input_roundtrip_over_unix_socket() {
|
||||
let server_handle = thread::spawn(move || {
|
||||
let bridge = LocalBridge::accept(&server_path).expect("failed to accept");
|
||||
|
||||
let inputs = bridge.receive_inputs().expect("failed to receive inputs");
|
||||
let inputs = match bridge.receive().expect("failed to receive") {
|
||||
Some(Inbound::Inputs(inputs)) => inputs,
|
||||
other => panic!("expected inputs, got {other:?}"),
|
||||
};
|
||||
|
||||
assert_eq!(inputs.len(), 2);
|
||||
assert_eq!(inputs[0].tick, 10);
|
||||
|
||||
Reference in New Issue
Block a user