summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-06 18:41:04 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-06 18:41:04 -0400
commit511b04bb455d483d69412501b98503797d79305b (patch)
treedf543e84517ccb70103f655a17dc6c5a7ce31e2f
parentd64db47867cdd54cdc005333203436fce193c4fc (diff)
downloadrust-irc-511b04bb455d483d69412501b98503797d79305b.tar.gz
rust-irc-511b04bb455d483d69412501b98503797d79305b.zip
have the example client respond to PING commands
-rw-r--r--examples/client.rs10
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()));
+ },
+ _ => {},
+ }
});
}