pub struct Message {
pub msg_type: MessageType,
pub session: Option<SessionId>,
pub channel: Option<String>,
pub payload: Option<MessagePayload>,
}Expand description
A message sent between frontend, relay, and backend.
All messages carry a type field that identifies the variant,
an optional session ID for session-scoped messages, and
a type-specific payload.
Fields§
§msg_type: MessageTypeMessage type identifier (e.g. “input”, “output”, “resize”).
session: Option<SessionId>Session ID, present on session-scoped messages.
channel: Option<String>The channel inside the session a message belongs to, for a backend
that carries several of its machine’s sessions in one relay session:
an opaque ID (valid_channel), never a session’s name. The relay
sets it on what a frontend sends (the channel it joined), and sends
the backend’s output on a channel only to the frontends that joined
it. Left out for the session as a whole.
payload: Option<MessagePayload>Type-specific payload data.
Implementations§
Source§impl Message
impl Message
Sourcepub fn on_channel(self, channel: Option<String>) -> Self
pub fn on_channel(self, channel: Option<String>) -> Self
This message, on channel.
Source§impl Message
impl Message
Sourcepub fn session_create() -> Self
pub fn session_create() -> Self
Create a new session creation message.
Sourcepub fn session_create_replaying() -> Self
pub fn session_create_replaying() -> Self
Create a session creation message from a backend that replays recent output to joining frontends.
Sourcepub fn session_join(session: SessionId) -> Self
pub fn session_join(session: SessionId) -> Self
Create a new session join message.
Sourcepub fn session_join_with_history(
session: SessionId,
history: u32,
rows: u16,
) -> Self
pub fn session_join_with_history( session: SessionId, history: u32, rows: u16, ) -> Self
Create a session join that asks for history lines of the session’s
history before its screen (#92), for a terminal of rows rows; with
none asked, a plain join.
Sourcepub fn session_joined(session: SessionId, frontend_token: String) -> Self
pub fn session_joined(session: SessionId, frontend_token: String) -> Self
Create a session joined confirmation, as a frontend gets it.
Sourcepub fn session_created(
session: SessionId,
frontend_token: String,
resume_secret: String,
) -> Self
pub fn session_created( session: SessionId, frontend_token: String, resume_secret: String, ) -> Self
Create a session joined confirmation for the backend that created or resumed the session, with its resume secret.
Sourcepub fn session_resume(session: SessionId, secret: String) -> Self
pub fn session_resume(session: SessionId, secret: String) -> Self
Create a session resume request.
Sourcepub fn frontend_joined(
session: SessionId,
frontend: u64,
history: u32,
rows: u16,
) -> Self
pub fn frontend_joined( session: SessionId, frontend: u64, history: u32, rows: u16, ) -> Self
Create a notice to the backend that a frontend joined.
Sourcepub fn replay(session: SessionId, frontend: u64, data: Vec<u8>) -> Self
pub fn replay(session: SessionId, frontend: u64, data: Vec<u8>) -> Self
Create a replay of recent output for a joining frontend.
Sourcepub fn backend_away(session: SessionId) -> Self
pub fn backend_away(session: SessionId) -> Self
Create a notice that the session’s backend dropped.
Sourcepub fn backend_back(session: SessionId) -> Self
pub fn backend_back(session: SessionId) -> Self
Create a notice that the session’s backend is back.
Sourcepub fn session_left(session: SessionId) -> Self
pub fn session_left(session: SessionId) -> Self
Create a session left message.
Sourcepub fn session_error(session: Option<SessionId>, reason: String) -> Self
pub fn session_error(session: Option<SessionId>, reason: String) -> Self
Create a session error message; session is None for an error that
comes before the connection has a session (a failed auth, say).
Sourcepub fn input(session: SessionId, data: Vec<u8>) -> Self
pub fn input(session: SessionId, data: Vec<u8>) -> Self
Create an input (keyboard/mouse) message.
Sourcepub fn paste_input(session: SessionId, data: Vec<u8>) -> Self
pub fn paste_input(session: SessionId, data: Vec<u8>) -> Self
Create an input message for bytes inside a bracketed paste.
Sourcepub fn sealed_resize(session: SessionId, data: Vec<u8>) -> Self
pub fn sealed_resize(session: SessionId, data: Vec<u8>) -> Self
Create a resize message carrying a sealed size.