summaryrefslogtreecommitdiff
path: root/server/examples
diff options
context:
space:
mode:
Diffstat (limited to 'server/examples')
-rw-r--r--server/examples/client.rs70
1 files changed, 0 insertions, 70 deletions
diff --git a/server/examples/client.rs b/server/examples/client.rs
deleted file mode 100644
index 70b1bb00..00000000
--- a/server/examples/client.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Hurry Curry! - a game about cooking
- Copyright 2024 metamuffin
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, version 3 of the License only.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-*/
-use hurrycurry_protocol::{glam::Vec2, PacketC, PacketS};
-use std::{
- io::{stdin, BufRead, BufReader, Write},
- net::TcpStream,
- thread,
-};
-
-fn main() {
- let mut sock = TcpStream::connect("127.0.0.1:27031").unwrap();
-
- let sock2 = BufReader::new(sock.try_clone().unwrap());
- thread::spawn(move || {
- for line in sock2.lines() {
- let line = line.unwrap();
- let packet: PacketC = serde_json::from_str(&line).unwrap();
- eprintln!("{packet:?}")
- }
- });
-
- for line in stdin().lines() {
- let line = line.unwrap();
- let mut toks = line.split(" ");
- let packet = match toks.next().unwrap() {
- "j" => PacketS::Join {
- character: 0,
- name: "test".to_string(),
- },
- "p" => PacketS::Position {
- pos: Vec2::new(
- toks.next().unwrap().parse().unwrap(),
- toks.next().unwrap().parse().unwrap(),
- ),
- boosting: false,
- rot: 0.,
- },
- "i" => PacketS::Position {
- pos: Vec2::new(
- toks.next().unwrap().parse().unwrap(),
- toks.next().unwrap().parse().unwrap(),
- ),
- boosting: false,
- rot: toks.next().unwrap_or("0").parse().unwrap(),
- },
- _ => {
- println!("unknown");
- continue;
- }
- };
- sock.write_all(serde_json::to_string(&packet).unwrap().as_bytes())
- .unwrap();
- sock.write_all(b"\n").unwrap();
- }
-}