pub struct Session {
id: String,
pub terminal: Terminal,
scrollback: Mutex<VecDeque<ScrollbackEvent>>,
scrollback_bytes: Mutex<usize>,
scrollback_limit: usize,
clients: AtomicUsize,
detached_at: Mutex<Option<Instant>>,
window_size: Sender<(u16, u16)>,
orphan_timeout: Duration,
}Expand description
A persistent terminal session.
Tracks connected clients, buffers recent output for replay on reconnect, and detects when the session becomes orphaned.
Fields§
§id: String§terminal: Terminal§scrollback: Mutex<VecDeque<ScrollbackEvent>>§scrollback_bytes: Mutex<usize>§scrollback_limit: usize§clients: AtomicUsize§detached_at: Mutex<Option<Instant>>§window_size: Sender<(u16, u16)>§orphan_timeout: DurationImplementations§
Source§impl Session
impl Session
Sourcepub fn new(
terminal: Terminal,
output_rx: Receiver<Vec<u8>>,
scrollback_limit: usize,
orphan_timeout: Duration,
) -> Arc<Self>
pub fn new( terminal: Terminal, output_rx: Receiver<Vec<u8>>, scrollback_limit: usize, orphan_timeout: Duration, ) -> Arc<Self>
Create a new session.
orphan_timeout controls how long a session with no attached clients
survives before the reaper removes it (default: DEFAULT_ORPHAN_TIMEOUT).
Sourcefn push_scrollback(&self, event: ScrollbackEvent)
fn push_scrollback(&self, event: ScrollbackEvent)
Push an event into the scrollback ring buffer, evicting old events when the byte budget is exceeded.
Sourcepub fn attach(&self) -> AttachResult
pub fn attach(&self) -> AttachResult
Attach a client: increment the counter, subscribe to live output, and return the scrollback event log. The subscription and snapshot are taken under the same lock so no output is lost.
Sourcepub fn set_window_size(&self, rows: u16, cols: u16)
pub fn set_window_size(&self, rows: u16, cols: u16)
Update the current PTY window size (broadcast to viewers) and record the resize in the scrollback log so replay clients see it too.
Sourcepub fn client_count(&self) -> usize
pub fn client_count(&self) -> usize
Number of currently attached clients.