diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-09-06 18:41:04 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-09-06 18:41:04 -0400 |
commit | 511b04bb455d483d69412501b98503797d79305b (patch) | |
tree | df543e84517ccb70103f655a17dc6c5a7ce31e2f /examples | |
parent | d64db47867cdd54cdc005333203436fce193c4fc (diff) | |
download | rust-irc-511b04bb455d483d69412501b98503797d79305b.tar.gz rust-irc-511b04bb455d483d69412501b98503797d79305b.zip |
have the example client respond to PING commands
Diffstat (limited to 'examples')
-rw-r--r-- | examples/client.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/client.rs b/examples/client.rs index ef0f7d2..16065f4 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -1,9 +1,17 @@ extern crate irc; +use irc::constants::{Ping, Pong}; + fn main () { let builder = irc::ClientBuilder::new("doytest", "chat.freenode.net"); let client = builder.connect(); - client.run_loop_with(|_client, m| { + client.run_loop_with(|client, m| { println!("{}", m); + match m.message_type() { + &Ping => { + client.write(irc::Message::new(None, Pong, m.params().clone())); + }, + _ => {}, + } }); } |