aboutsummaryrefslogtreecommitdiffstats
path: root/examples/client.rs
diff options
context:
space:
mode:
authorZachary Dremann <dremann@gmail.com>2014-06-25 15:50:16 -0400
committerZachary Dremann <dremann@gmail.com>2014-06-25 16:06:44 -0400
commitae22f22a931b207301681f2fc948e8e9cfd1daf7 (patch)
tree3e1b8d6ef91f010fe048bf5d205b90d6f16b68d2 /examples/client.rs
parent4beb868e0ca2aa5ad9c29e4ba934c0fd8fc2501e (diff)
downloadrusty-irc-ae22f22a931b207301681f2fc948e8e9cfd1daf7.tar.gz
rusty-irc-ae22f22a931b207301681f2fc948e8e9cfd1daf7.zip
Updated for Cargo
Diffstat (limited to 'examples/client.rs')
-rw-r--r--examples/client.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/examples/client.rs b/examples/client.rs
deleted file mode 100644
index 9c5e15a..0000000
--- a/examples/client.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-extern crate irc;
-extern crate libc;
-
-use std::io::stdio;
-
-use irc::IrcClient;
-
-fn main() {
- let mut stderr = stdio::stderr();
-
- let mut args = std::os::args().move_iter();
- args.next();
- let host = args.next().expect("No hostname passed");
- let port: u16 = from_str(args.next().unwrap_or_else(|| { let _ = writeln!(stderr, "No port given. Assuming 6667."); "6667".to_string() }).as_slice())
- .expect("Port must be a number");
-
- drop(args);
-
- let (tx, rx) = channel();
-
- let nicks = (vec!["rusti-irc".to_string()]).move_iter();
- let config = irc::ClientConfig {
- nicks: nicks,
- username: "dremann".to_string(),
- real_name: "Zachary Dremann".to_string()
- };
-
- let client = IrcClient::new(config, host.as_slice(), port, tx).unwrap();
- let sender = client.sender().clone();
-
- spawn(proc() {
- let mut stdin = stdio::stdin();
- for line in stdin.lines() {
- match line {
- Ok(s) => {
- match from_str(s.as_slice()) {
- Some(msg) => { if sender.send_opt(msg).is_err() { break; } },
- None => ()
- }
- }
- Err(_) => break,
- }
- }
- });
-
- for msg in rx.iter() {
- let c = client.clone();
- println!("{}", c.nick());
- println!("{} {}", msg.prefix, msg.command);
- }
-
- unsafe { libc::exit(0); }
-}