diff --git a/README.md b/README.md index 67e902c..a28d0df 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,7 @@ extern crate irc; use irc::client::prelude::*; fn main() { - let irc_server = IrcServer::new("config.json").unwrap(); - let server = Wrapper::new(&irc_server); + let server = IrcServer::new("config.json").unwrap(); server.identify().unwrap(); for message in server.iter() { // Do message processing. diff --git a/examples/autoreconnect.rs b/examples/autoreconnect.rs index d868638..6c5fdd8 100644 --- a/examples/autoreconnect.rs +++ b/examples/autoreconnect.rs @@ -12,11 +12,10 @@ fn main() { channels: Some(vec![format!("#vana")]), .. Default::default() }; - let irc_server = Arc::new(IrcServer::from_config(config).unwrap()); - irc_server.conn().set_keepalive(Some(5)).unwrap(); - // The wrapper provides us with methods like send_privmsg(...) and identify(...) + let server = Arc::new(IrcServer::from_config(config).unwrap()); + server.conn().set_keepalive(Some(5)).unwrap(); + let server = server.clone(); let _ = spawn(move || { - let server = Wrapper::new(&*irc_server); server.identify().unwrap(); loop { let mut quit = false; @@ -36,7 +35,7 @@ fn main() { } } if quit { break } - irc_server.reconnect().unwrap(); + server.reconnect().unwrap(); server.identify().unwrap(); } }).join(); diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index 30f9f16..e62bc8e 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -12,12 +12,9 @@ fn main() { channels: Some(vec![format!("#vana")]), .. Default::default() }; - let irc_server = Arc::new(IrcServer::from_config(config).unwrap()); - // The wrapper provides us with methods like send_privmsg(...) and identify(...) - let server = Wrapper::new(&*irc_server); + let server = Arc::new(IrcServer::from_config(config).unwrap()); server.identify().unwrap(); - let server = irc_server.clone(); - // We won't use a wrapper here because we don't need the added functionality. + let server = server.clone(); let _ = spawn(move || { for msg in server.iter() { print!("{}", msg.unwrap().into_string()); diff --git a/examples/simple.rs b/examples/simple.rs index b29c8af..75de009 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -11,9 +11,7 @@ fn main() { channels: Some(vec![format!("#vana")]), .. Default::default() }; - let irc_server = IrcServer::from_config(config).unwrap(); - // The wrapper provides us with methods like send_privmsg(...) and identify(...) - let server = Wrapper::new(&irc_server); + let server = IrcServer::from_config(config).unwrap(); server.identify().unwrap(); for message in server.iter() { let message = message.unwrap(); // We'll just panic if there's an error. diff --git a/examples/simple_cmd.rs b/examples/simple_cmd.rs index dbfb9d7..76f1d52 100644 --- a/examples/simple_cmd.rs +++ b/examples/simple_cmd.rs @@ -11,9 +11,7 @@ fn main() { channels: Some(vec![format!("#vana")]), .. Default::default() }; - let irc_server = IrcServer::from_config(config).unwrap(); - // The wrapper provides us with methods like send_privmsg(...) and identify(...) - let server = Wrapper::new(&irc_server); + let server = IrcServer::from_config(config).unwrap(); server.identify().unwrap(); for command in server.iter_cmd() { // Use of unwrap() on the results of iter_cmd() is currently discouraged on servers where diff --git a/examples/simple_ssl.rs b/examples/simple_ssl.rs index cae35c8..7e9c6d8 100644 --- a/examples/simple_ssl.rs +++ b/examples/simple_ssl.rs @@ -12,9 +12,7 @@ fn main() { use_ssl: Some(true), .. Default::default() }; - let irc_server = IrcServer::from_config(config).unwrap(); - // The wrapper provides us with methods like send_privmsg(...) and identify(...) - let server = Wrapper::new(&irc_server); + let server = IrcServer::from_config(config).unwrap(); server.identify().unwrap(); for message in server.iter() { let message = message.unwrap(); // We'll just panic if there's an error. diff --git a/examples/tweeter.rs b/examples/tweeter.rs index 9e7e536..9750f96 100644 --- a/examples/tweeter.rs +++ b/examples/tweeter.rs @@ -15,14 +15,12 @@ fn main() { channels: Some(vec![format!("#vana")]), .. Default::default() }; - let irc_server = Arc::new(IrcServer::from_config(config).unwrap()); - let irc_server2 = irc_server.clone(); - // The wrapper provides us with methods like send_privmsg(...) and identify(...) - let server = Wrapper::new(&*irc_server2); + let server = Arc::new(IrcServer::from_config(config).unwrap()); server.identify().unwrap(); + let server2 = server.clone(); // Let's set up a loop that just prints the messages. spawn(move || { - irc_server.iter().map(|m| print!("{}", m.unwrap().into_string())).count(); + server2.iter().map(|m| print!("{}", m.unwrap().into_string())).count(); }); loop { server.send_privmsg("#vana", "TWEET TWEET").unwrap();