Struct sshx_server::session::Session
source · pub struct Session { /* private fields */ }
Expand description
In-memory state for a single sshx session.
Implementations§
source§impl Session
impl Session
sourcepub fn sequence_numbers(&self) -> SequenceNumbers
pub fn sequence_numbers(&self) -> SequenceNumbers
Return the sequence numbers for current shells.
sourcepub fn subscribe_broadcast(
&self,
) -> impl Stream<Item = Result<WsServer, BroadcastStreamRecvError>> + Unpin
pub fn subscribe_broadcast( &self, ) -> impl Stream<Item = Result<WsServer, BroadcastStreamRecvError>> + Unpin
Receive a notification on broadcasted message events.
sourcepub fn subscribe_shells(
&self,
) -> impl Stream<Item = Vec<(Sid, WsWinsize)>> + Unpin
pub fn subscribe_shells( &self, ) -> impl Stream<Item = Vec<(Sid, WsWinsize)>> + Unpin
Receive a notification every time the set of shells is changed.
sourcepub fn subscribe_chunks(
&self,
id: Sid,
chunknum: u64,
) -> impl Stream<Item = (u64, Vec<Bytes>)> + '_
pub fn subscribe_chunks( &self, id: Sid, chunknum: u64, ) -> impl Stream<Item = (u64, Vec<Bytes>)> + '_
Subscribe for chunks from a shell, until it is closed.
sourcepub fn add_shell(&self, id: Sid, center: (i32, i32)) -> Result<()>
pub fn add_shell(&self, id: Sid, center: (i32, i32)) -> Result<()>
Add a new shell to the session.
sourcepub fn close_shell(&self, id: Sid) -> Result<()>
pub fn close_shell(&self, id: Sid) -> Result<()>
Terminates an existing shell.
sourcepub fn move_shell(&self, id: Sid, winsize: Option<WsWinsize>) -> Result<()>
pub fn move_shell(&self, id: Sid, winsize: Option<WsWinsize>) -> Result<()>
Change the size of a terminal, notifying clients if necessary.
sourcepub fn add_data(&self, id: Sid, data: Bytes, seq: u64) -> Result<()>
pub fn add_data(&self, id: Sid, data: Bytes, seq: u64) -> Result<()>
Receive new data into the session.
sourcepub fn list_users(&self) -> Vec<(Uid, WsUser)>
pub fn list_users(&self) -> Vec<(Uid, WsUser)>
List all the users in the session.
sourcepub fn update_user(&self, id: Uid, f: impl FnOnce(&mut WsUser)) -> Result<()>
pub fn update_user(&self, id: Uid, f: impl FnOnce(&mut WsUser)) -> Result<()>
Update a user in place by ID, applying a callback to the object.
sourcepub fn user_scope(&self, id: Uid) -> Result<impl Drop + '_>
pub fn user_scope(&self, id: Uid) -> Result<impl Drop + '_>
Add a new user, and return a guard that removes the user when dropped.
sourcepub fn send_latency_measurement(&self, latency: u64)
pub fn send_latency_measurement(&self, latency: u64)
Send a measurement of the shell latency.
sourcepub fn last_accessed(&self) -> Instant
pub fn last_accessed(&self) -> Instant
Returns the timestamp of the last backend client activity.
sourcepub fn update_tx(&self) -> &Sender<ServerMessage>
pub fn update_tx(&self) -> &Sender<ServerMessage>
Access the sender of the client message channel for this session.
sourcepub fn update_rx(&self) -> &Receiver<ServerMessage>
pub fn update_rx(&self) -> &Receiver<ServerMessage>
Access the receiver of the client message channel for this session.
sourcepub fn sync_now(&self)
pub fn sync_now(&self)
Mark the session as requiring an immediate storage sync.
This is needed for consistency when creating new shells, removing old shells, or updating the ID counter. If these operations are lost in a server restart, then the snapshot that contains them would be invalid compared to the current backend client state.
Note that it is not necessary to do this all the time though, since that would put too much pressure on the database. Lost terminal data is already re-synchronized periodically.
sourcepub async fn sync_now_wait(&self)
pub async fn sync_now_wait(&self)
Resolves when the session has been marked for an immediate sync.
sourcepub async fn terminated(&self)
pub async fn terminated(&self)
Resolves when the session has received a shutdown signal.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request