diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-18 12:39:33 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-18 12:39:33 +0200 |
commit | 2a31d26fca33789ccf8ea28cdb214d20dd29f85d (patch) | |
tree | 426faa4d55905ecacdb9a1a4beca6d5a1ab97953 /server/examples | |
parent | c4ae8c2df44cac2a8b3e4c8db43c2870b7d2bf69 (diff) | |
download | hurrycurry-2a31d26fca33789ccf8ea28cdb214d20dd29f85d.tar hurrycurry-2a31d26fca33789ccf8ea28cdb214d20dd29f85d.tar.bz2 hurrycurry-2a31d26fca33789ccf8ea28cdb214d20dd29f85d.tar.zst |
serve-authorative movement
Diffstat (limited to 'server/examples')
-rw-r--r-- | server/examples/client.rs | 70 |
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(); - } -} |