fix(bridge): use named MessagePack format for wire compatibility
Client-side Protocol.gd expects rmp_serde::to_vec_named() (maps with string keys), but LocalBridge was using to_vec() (compact positional arrays). Fix send_snapshot and update all test serialization calls to match actual wire format. Also change EOF from Ok(vec![]) to BridgeError::Transport so bridge systems can detect disconnects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ impl LocalBridge {
|
||||
|
||||
impl SimBridge for LocalBridge {
|
||||
fn send_snapshot(&self, snapshot: &ObserverSnapshot) -> Result<(), BridgeError> {
|
||||
let payload = rmp_serde::to_vec(snapshot)?;
|
||||
let payload = rmp_serde::to_vec_named(snapshot)?;
|
||||
|
||||
let mut writer = self.writer.lock().expect("writer mutex poisoned");
|
||||
write_framed(writer.get_mut(), &payload)?;
|
||||
@@ -99,10 +99,7 @@ impl SimBridge for LocalBridge {
|
||||
tracing::trace!("received {} inputs", inputs.len());
|
||||
Ok(inputs)
|
||||
}
|
||||
None => {
|
||||
tracing::trace!("received EOF, returning empty input vec");
|
||||
Ok(Vec::new())
|
||||
}
|
||||
None => Err(BridgeError::Transport("client disconnected (EOF)".into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user