pub struct Server { /* private fields */ }Expand description
The build’s end of the link, for one client: it turns the client’s
lines into answers over the App the backend runs, and gives the
backend a play’s input frame by frame. The backend makes one per
connection.
Each frame the backend calls handle for each line
read and sends the answers; input before
App::frame, adding what it gives after the devices’ input; then
after_frame, sending what it gives; if
wants_screenshot, reads the window and
sends screenshot’s line; and if
wants_snapshot, takes a heap snapshot and
sends snapshot’s.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(token: String, game: String) -> Self
pub fn new(token: String, game: String) -> Self
The server of a build whose token is token, of the game game
(the window’s title).
Sourcepub fn handle<G: GameData>(&mut self, line: &str, app: &App<G>) -> Handled
pub fn handle<G: GameData>(&mut self, line: &str, app: &App<G>) -> Handled
What line (without its line break) asks of app.
Sourcepub fn input<G: GameData>(&mut self, app: &App<G>, out: &mut Vec<RawInputEvent>)
pub fn input<G: GameData>(&mut self, app: &App<G>, out: &mut Vec<RawInputEvent>)
This frame’s input from the play being played, if one is: the next
frame of its steps, put in out after what is there. While the
game loads or is suspended the steps wait. A play whose game failed
to load, or one of whose actions can’t be pressed, ends with an
error, having played nothing more.
Sourcepub fn after_frame<G: GameData>(&mut self, app: &App<G>) -> Vec<String>
pub fn after_frame<G: GameData>(&mut self, app: &App<G>) -> Vec<String>
The answers due now that app’s frame has run: a play’s whose last
frame it was, then those of the requests that waited behind it, up
to the next play or picture.
Sourcepub fn wants_screenshot(&self) -> bool
pub fn wants_screenshot(&self) -> bool
Whether the backend should read the window after this frame and
answer with screenshot.
Sourcepub fn screenshot(&mut self, png: &[u8], width: u32, height: u32) -> String
pub fn screenshot(&mut self, png: &[u8], width: u32, height: u32) -> String
The answer to a Request::Screenshot: png, the window’s
picture of width × height pixels. Requests behind it are
answered from the next after_frame.
Sourcepub fn wants_snapshot(&self) -> bool
pub fn wants_snapshot(&self) -> bool
Whether the backend should take a heap snapshot after this frame
and answer with snapshot.
Sourcepub fn snapshot<G: GameData>(
&mut self,
app: &App<G>,
snapshot: Option<HeapSnapshot>,
) -> String
pub fn snapshot<G: GameData>( &mut self, app: &App<G>, snapshot: Option<HeapSnapshot>, ) -> String
The answer to a Request::Perf that asked for a snapshot:
app’s records it asked for, and snapshot, the backend’s
(App::heap_snapshot; None where it takes none). Requests
behind it are answered from the next
after_frame.