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

source

pub fn snapshot(&self) -> Result<Vec<u8>>

Snapshot the session, returning a compressed representation.

source

pub fn restore(data: &[u8]) -> Result<Self>

Restore the session from a previous compressed snapshot.

source§

impl Session

source

pub fn new(metadata: Metadata) -> Self

Construct a new session.

source

pub fn metadata(&self) -> &Metadata

Returns the metadata for this session.

source

pub fn counter(&self) -> &IdCounter

Gives access to the ID counter for obtaining new IDs.

source

pub fn sequence_numbers(&self) -> SequenceNumbers

Return the sequence numbers for current shells.

source

pub fn subscribe_broadcast( &self, ) -> impl Stream<Item = Result<WsServer, BroadcastStreamRecvError>> + Unpin

Receive a notification on broadcasted message events.

source

pub fn subscribe_shells( &self, ) -> impl Stream<Item = Vec<(Sid, WsWinsize)>> + Unpin

Receive a notification every time the set of shells is changed.

source

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.

source

pub fn add_shell(&self, id: Sid, center: (i32, i32)) -> Result<()>

Add a new shell to the session.

source

pub fn close_shell(&self, id: Sid) -> Result<()>

Terminates an existing shell.

source

pub fn move_shell(&self, id: Sid, winsize: Option<WsWinsize>) -> Result<()>

Change the size of a terminal, notifying clients if necessary.

source

pub fn add_data(&self, id: Sid, data: Bytes, seq: u64) -> Result<()>

Receive new data into the session.

source

pub fn list_users(&self) -> Vec<(Uid, WsUser)>

List all the users in the session.

source

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.

source

pub fn user_scope(&self, id: Uid) -> Result<impl Drop + '_>

Add a new user, and return a guard that removes the user when dropped.

source

pub fn send_chat(&self, id: Uid, msg: &str) -> Result<()>

Send a chat message into the room.

source

pub fn send_latency_measurement(&self, latency: u64)

Send a measurement of the shell latency.

source

pub fn access(&self)

Register a backend client heartbeat, refreshing the timestamp.

source

pub fn last_accessed(&self) -> Instant

Returns the timestamp of the last backend client activity.

source

pub fn update_tx(&self) -> &Sender<ServerMessage>

Access the sender of the client message channel for this session.

source

pub fn update_rx(&self) -> &Receiver<ServerMessage>

Access the receiver of the client message channel for this session.

source

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.

source

pub async fn sync_now_wait(&self)

Resolves when the session has been marked for an immediate sync.

source

pub fn shutdown(&self)

Send a termination signal to exit this session.

source

pub async fn terminated(&self)

Resolves when the session has received a shutdown signal.

Trait Implementations§

source§

impl Debug for Session

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more