feat: phase 2 — handshake, message writers, and server message dispatch
handshake.rs: - Config, PixelFormat, ServerInit, Session types - connect() walks all 11 handshake steps per aw.g() line 226 - Auth error mapping from aw.a(int) line 350 (7 error codes) msg.rs — client-to-server writers: - SetEncodings (type 2), FramebufferUpdateRequest (type 3) - KeyEvent (type 4), PointerEvent (type 5, 8 bytes) - PingResponse (type 149), BandwidthMarker (type 151) msg.rs — server message dispatch: - ServerMsg enum covering all 15 message types - Readers for ping, bandwidth probe, ack, debug string, RFB command, server cut text, server name update, layout/locale, RDP event, FB update header examples/handshake.rs: connects and prints session info. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
47
crates/ericrfb/examples/handshake.rs
Normal file
47
crates/ericrfb/examples/handshake.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
use std::env;
|
||||
|
||||
use ericrfb::handshake::{Config, connect};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
let host = args
|
||||
.iter()
|
||||
.position(|a| a == "--host")
|
||||
.and_then(|i| args.get(i + 1))
|
||||
.expect("usage: --host <ip> --applet-id <token> [--port <port>]");
|
||||
|
||||
let applet_id = args
|
||||
.iter()
|
||||
.position(|a| a == "--applet-id")
|
||||
.and_then(|i| args.get(i + 1))
|
||||
.expect("usage: --host <ip> --applet-id <token> [--port <port>]");
|
||||
|
||||
let port: u16 = args
|
||||
.iter()
|
||||
.position(|a| a == "--port")
|
||||
.and_then(|i| args.get(i + 1))
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(443);
|
||||
|
||||
let cfg = Config::new(host, port, applet_id);
|
||||
println!("Connecting to {}:{}...", cfg.host, cfg.port);
|
||||
|
||||
match connect(&cfg) {
|
||||
Ok(session) => {
|
||||
println!(
|
||||
"Connected: name={:?}, {}x{}, version={}.{}, format={}",
|
||||
session.server_name,
|
||||
session.width(),
|
||||
session.height(),
|
||||
session.server_version.0,
|
||||
session.server_version.1,
|
||||
session.pixel_format.label,
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Handshake failed: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user