summaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/client/run.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/client/src/client/run.rs b/client/src/client/run.rs
index d955cea..88cc056 100644
--- a/client/src/client/run.rs
+++ b/client/src/client/run.rs
@@ -2,7 +2,7 @@
use crate::{Client, ServerConnection};
-use bowshock::net::{DEFAULT_SERVER_PORT, Request};
+use bowshock::net::{Request, Response, DEFAULT_SERVER_PORT};
use bzipper::FixedString;
impl Client {
@@ -12,8 +12,27 @@ impl Client {
let mut connection = ServerConnection::new(server_addr);
- let join_request = Request::PlayerJoin { username: FixedString::try_from("delta").unwrap() };
- connection.send_request(&join_request);
+ let mut request = Request::Ping;
+ connection.send_request(&request);
+
+ let mut response = connection.recieve_response();
+
+ eprintln!("got response {response:?}");
+
+ request = Request::Join { username: FixedString::try_from("delta").unwrap() };
+ connection.send_request(&request);
+
+ response = connection.recieve_response();
+
+ eprintln!("got response {response:?}");
+
+ let Response::JoinAccepted { token } = response else {
+ eprintln!("expected approved join :(");
+ return Err(0x1);
+ };
+
+ request = Request::Quit { token };
+ connection.send_request(&request);
Ok(())
}