From 213aa0c62f37e7be212864b1f4178a7de1e1092b Mon Sep 17 00:00:00 2001 From: famfo Date: Wed, 3 Nov 2021 17:21:38 +0100 Subject: [PATCH] Ping-Pong --- src/lib.rs | 9 +++++---- src/main.rs | 4 +--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9396342..dacec32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ impl Client { fn write(&mut self, data: &str) -> Result<(), Error> { let formatted = { - let new = format!("{}\n", data); + let new = format!("{}\r\n", data); Cow::Owned(new) as Cow }; @@ -101,15 +101,16 @@ impl Client { } USER(username, s1, s2, realname) => { let formatted = format!("USER {} {} {} :{}", username, s1, s2, realname); - Cow::Owned(formatted) as Cow } NICK(nickname) => { let formatted = format!("NICK {}", nickname); - Cow::Owned(formatted) as Cow } - _ => Cow::Borrowed("") as Cow, + PING(ping) => { + let formatted = format!("PONG {}", ping); + Cow::Owned(formatted) as Cow + } }; self.write(&computed)?; diff --git a/src/main.rs b/src/main.rs index 5e48209..4188dbe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ macro_rules! loop_n { fn main() -> Result<(), std::io::Error> { let config = Config::new("test", Some("test"), Some("+B")); let mut client = - Client::new("192.168.1.28", 6667, config).expect("Unable to connect to IRC server"); + Client::new("192.168.178.100", 6667, config).expect("Unable to connect to IRC server"); client.identify()?; loop { @@ -20,6 +20,4 @@ fn main() -> Result<(), std::io::Error> { print!("{}", line); } } - - Ok(()) }