Ping-Pong

This commit is contained in:
famfo 2021-11-03 17:21:38 +01:00 committed by Yash Karandikar
parent c23e0b7bdf
commit 213aa0c62f
2 changed files with 6 additions and 7 deletions

View file

@ -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<str>
};
@ -101,15 +101,16 @@ impl Client {
}
USER(username, s1, s2, realname) => {
let formatted = format!("USER {} {} {} :{}", username, s1, s2, realname);
Cow::Owned(formatted) as Cow<str>
}
NICK(nickname) => {
let formatted = format!("NICK {}", nickname);
Cow::Owned(formatted) as Cow<str>
}
_ => Cow::Borrowed("") as Cow<str>,
PING(ping) => {
let formatted = format!("PONG {}", ping);
Cow::Owned(formatted) as Cow<str>
}
};
self.write(&computed)?;

View file

@ -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(())
}