3 use crate::server::pkts as server_bound;
4 use connect::{ConnectDatagram, Connection, ConnectionReader, ConnectionWriter, StreamExt};
6 use tokio::sync::Mutex as AsyncMutex;
9 pub conn: AsyncMutex<ConnectionWriter>,
14 pub async fn run(addr: &str, quit: Quit) {
15 let (reader, writer) = Connection::tcp_client(addr).await.unwrap().split();
18 conn: AsyncMutex::new(writer),
25 async fn handle(&self, msg: &ConnectDatagram) {
26 println!("{}", msg.recipient());
29 async fn run_loop(self, mut reader: ConnectionReader) {
30 let mut quit = self.quit.subscribe();
35 &server_bound::Login {
36 name: "player".into(),
37 pwd: "password123".into(),
44 msg = reader.next() => match msg {
45 Some(msg) => self.handle(&msg).await,
47 trace!("Server closed connection");
52 trace!("Quit signal received");
55 else => unreachable!("Quit channel broke"),
59 info!("Disconnected");