Include "x" (exit) event in ALiS stream

This commit is contained in:
Marcin Kulik
2025-05-29 21:18:01 +02:00
parent 2aec6f690b
commit 31cc393efe
2 changed files with 18 additions and 1 deletions

View File

@@ -137,5 +137,18 @@ fn serialize_event(event: Event, prev_event_time: u64) -> (Vec<u8>, u64) {
(msg, time)
}
Exit(id, time, status) => {
let id_bytes = leb128::encode(id);
let time_bytes = leb128::encode(time - prev_event_time);
let status_bytes = leb128::encode(status.max(0) as u64);
let mut msg = vec![b'x'];
msg.extend_from_slice(&id_bytes);
msg.extend_from_slice(&time_bytes);
msg.extend_from_slice(&status_bytes);
(msg, time)
}
}
}

View File

@@ -45,6 +45,7 @@ pub enum Event {
Input(u64, u64, String),
Resize(u64, u64, TtySize),
Marker(u64, u64, String),
Exit(u64, u64, i32),
}
impl Stream {
@@ -112,7 +113,10 @@ async fn run(
stream_time = time;
}
session::Event::Exit(_time, _status) => {}
session::Event::Exit(time, status) => {
let _ = broadcast_tx.send(Event::Exit(last_event_id, time, status));
stream_time = time;
}
}
}