summaryrefslogtreecommitdiffstats
path: root/examples/client.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-09 01:06:08 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-09 01:11:26 -0400
commitfa9defc897653f92fa289871ad3905ad672fc698 (patch)
tree7aaec05193064a1423cb4dd223b6ce20ab4a1aa0 /examples/client.rs
parent6bf08295188b48c2c0a141546fc67f1457f40961 (diff)
downloadrust-irc-fa9defc897653f92fa289871ad3905ad672fc698.tar.gz
rust-irc-fa9defc897653f92fa289871ad3905ad672fc698.zip
add callbacks for all messages
i'm not sure that all of these callbacks (or parameters) are valid for clients, but they're all there for now for completeness
Diffstat (limited to 'examples/client.rs')
-rw-r--r--examples/client.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/client.rs b/examples/client.rs
index ab1ef42..236b07e 100644
--- a/examples/client.rs
+++ b/examples/client.rs
@@ -1,6 +1,6 @@
extern crate irc;
-use irc::constants::{Ping, Pong};
+use irc::constants::Pong;
use irc::Client;
use std::io;
@@ -28,14 +28,16 @@ impl irc::Client for ExampleClient {
}
}
- fn on_message (client: &mut ExampleClient, m: &irc::Message) {
+ fn on_any_message (_client: &mut ExampleClient, m: &irc::Message) {
print!("{}", m.to_protocol_string());
- match *m.message_type() {
- Ping => {
- client.write(irc::Message::new(None, Pong, m.params().clone()));
- },
- _ => {},
- }
+ }
+
+ fn on_ping (client: &mut ExampleClient, _from: Option<&str>, server1: &str, server2: Option<&str>) {
+ 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));
}
}