From 1adaa2390928e87108208ec75e3748dd5a77fff3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 9 Sep 2014 18:57:53 -0400 Subject: the default PING implementation should reply with PONG --- examples/client.rs | 10 ---------- src/client.rs | 8 +++++++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/client.rs b/examples/client.rs index 0794329..c5f31a7 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -1,7 +1,5 @@ extern crate irc; -use irc::constants::Pong; - use std::io; pub struct ExampleClient; @@ -11,14 +9,6 @@ impl irc::ClientCallbacks for ExampleClient { print!("{}", m.to_protocol_string()); Ok(()) } - - fn on_ping (&mut self, client: &mut irc::Client, _from: Option<&str>, server1: &str, server2: Option<&str>) -> io::IoResult<()> { - let params = match server2 { - Some(server2) => vec![server1.to_string(), server2.to_string()], - None => vec![server1.to_string()], - }; - client.write(irc::Message::new(None, Pong, params)) - } } fn main () { diff --git a/src/client.rs b/src/client.rs index c4b507f..901070a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -867,7 +867,13 @@ pub trait ClientCallbacks { #[allow(unused_variable)] fn on_whowas (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, count: Option, server: Option<&str>) -> io::IoResult<()> { Ok(()) } #[allow(unused_variable)] fn on_kill (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, comment: &str) -> io::IoResult<()> { Ok(()) } - #[allow(unused_variable)] fn on_ping (&mut self, client: &mut Client, from: Option<&str>, server1: &str, server2: Option<&str>) -> io::IoResult<()> { Ok(()) } + #[allow(unused_variable)] fn on_ping (&mut self, client: &mut Client, from: Option<&str>, server1: &str, server2: Option<&str>) -> io::IoResult<()> { + let params = match server2 { + Some(server2) => vec![server1.to_string(), server2.to_string()], + None => vec![server1.to_string()], + }; + client.write(Message::new(None, Pong, params)) + } #[allow(unused_variable)] fn on_pong (&mut self, client: &mut Client, from: Option<&str>, daemon1: &str, daemon2: Option<&str>) -> io::IoResult<()> { Ok(()) } #[allow(unused_variable)] fn on_error (&mut self, client: &mut Client, from: Option<&str>, message: &str) -> io::IoResult<()> { Ok(()) } -- cgit v1.2.3