pub struct KvmSession<'a, M: ReceiverMode> { /* private fields */ }Expand description
Exclusive remote control of the source a receiver is connected to.
Created by Receiver::kvm, which borrows the receiver mutably, so a
receiver has at most one session at a time. The session lends the receiver
back as a restricted KvmReceiver through receiver,
so frames can be captured, and held, while keys, buttons and touches stay pressed
across them. The view offers mode-permitted capture, tally, PTZ, statistics
and metadata, without allowing application connection changes. For a
packet session, session.receiver() delivers owned or borrowed packets,
decoded media and events through its mode-specific capture methods.
To change source, successfully release_all, end the
session, change the connection through its owner, then start a new session.
Native disconnection, Discovery Server remote control and failed release
delivery can still leave input pressed on the previous source: release is
best effort and the session cannot address a source it has lost.
The session never reads the local clipboard: it sends only the text it is
given. It is Send and Sync, as the receiver is; its input methods take
&mut self, so one thread at a time sends input.
Every method that sends a message returns
Error::NativeOperationFailed, naming the SDK function, when the SDK did
not send it. Success is not a confirmation that the source acted on the
message. The session remembers which keys, buttons and touches it has
pressed, and dropping it releases them on a best-effort basis; call
release_all to learn whether that succeeded.
Implementations§
Source§impl<'a, M: ReceiverMode> KvmSession<'a, M>
impl<'a, M: ReceiverMode> KvmSession<'a, M>
Sourcepub fn receiver(&self) -> KvmReceiver<'a, M>
pub fn receiver(&self) -> KvmReceiver<'a, M>
Restricted receiver access for the session’s original receiver lifetime.
A frame captured through it can be held while the session’s input methods run, which is how a key, button or touch stays down across captured frames. The view cannot change the connection or recover an unrestricted receiver, even when moved to a scoped thread. Creating it allocates nothing and makes no SDK call or lock acquisition.
Sourcepub fn is_supported(&self) -> bool
pub fn is_supported(&self) -> bool
Whether the connected source accepts remote control. This can change during the session when that source enables or disables remote control.
Sourcepub fn mouse_down(&mut self, button: MouseButton) -> Result<()>
pub fn mouse_down(&mut self, button: MouseButton) -> Result<()>
Sourcepub fn mouse_up(&mut self, button: MouseButton) -> Result<()>
pub fn mouse_up(&mut self, button: MouseButton) -> Result<()>
Release a mouse button.
§Errors
Error::NativeOperationFailed when the SDK did not send the release;
the button stays recorded as pressed.
Sourcepub fn key_down(&mut self, keysym: u32) -> Result<()>
pub fn key_down(&mut self, keysym: u32) -> Result<()>
Press a key, identified by its X11 key symbol.
§Errors
Error::InvalidInput when the symbol is outside the range the SDK
accepts, and Error::NativeOperationFailed when the SDK did not
send the press.
Sourcepub fn wheel(&mut self, axis: WheelAxis, units: f32) -> Result<()>
pub fn wheel(&mut self, axis: WheelAxis, units: f32) -> Result<()>
Turn a mouse wheel by units notches; the sign gives the direction.
§Errors
Error::InvalidInput when units is not finite, and
Error::NativeOperationFailed when the SDK did not send the turn.
Sourcepub fn move_pointer(&mut self, x: f32, y: f32) -> Result<()>
pub fn move_pointer(&mut self, x: f32, y: f32) -> Result<()>
Move the pointer to (x, y), each a fraction of the source’s screen
from 0.0 (left, top) to 1.0 (right, bottom).
§Errors
Error::InvalidInput when a coordinate is outside 0.0..=1.0, and
Error::NativeOperationFailed when the SDK did not send the move.
Sourcepub fn set_clipboard_text(&mut self, text: &str) -> Result<()>
pub fn set_clipboard_text(&mut self, text: &str) -> Result<()>
Replace the source’s clipboard text.
§Errors
Error::InvalidCString when text contains a NUL, and
Error::NativeOperationFailed when the SDK did not send the text.
Sourcepub fn touch(&mut self, points: &[[f32; 2]]) -> Result<()>
pub fn touch(&mut self, points: &[[f32; 2]]) -> Result<()>
Report the current touch points, each an [x, y] fraction of the
source’s screen. An empty slice sends the same lift as
finish_touch.
§Errors
Error::InvalidInput when a coordinate is outside 0.0..=1.0 or
there are more points than the SDK can count, and
Error::NativeOperationFailed when the SDK did not send them.
Sourcepub fn finish_touch(&mut self) -> Result<()>
pub fn finish_touch(&mut self) -> Result<()>
Lift every touch.
§Errors
Error::NativeOperationFailed when the SDK did not send the lift;
the touches stay recorded.
Sourcepub fn release_all(&mut self) -> Result<()>
pub fn release_all(&mut self) -> Result<()>
Release every key, button and touch this session has pressed.
§Errors
Error::NativeOperationFailed for the first release the SDK did not
send. Every release is still attempted; those the SDK did not send
stay recorded as pressed, and a later call tries them again.