From 31cc393efe8c625378254e43838a244932adcecd Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Thu, 29 May 2025 21:18:01 +0200 Subject: [PATCH] Include "x" (exit) event in ALiS stream --- src/alis.rs | 13 +++++++++++++ src/stream.rs | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/alis.rs b/src/alis.rs index 55837b5..f5a6ac5 100644 --- a/src/alis.rs +++ b/src/alis.rs @@ -137,5 +137,18 @@ fn serialize_event(event: Event, prev_event_time: u64) -> (Vec, 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) + } } } diff --git a/src/stream.rs b/src/stream.rs index e5debcb..c50f661 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -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; + } } }