diff options
author | Zachary Dremann <dremann@gmail.com> | 2014-06-10 01:16:45 -0400 |
---|---|---|
committer | Zachary Dremann <dremann@gmail.com> | 2014-06-10 01:16:45 -0400 |
commit | a4dcf4b1d4586055e949062a5f5be141007ef58c (patch) | |
tree | 280159819d1cca3597ca76291276623fa3dd8349 /examples/client.rs | |
parent | 43494f6d5b17b17fec728341ce9ff25d3ba77d04 (diff) | |
download | rusty-irc-a4dcf4b1d4586055e949062a5f5be141007ef58c.tar.gz rusty-irc-a4dcf4b1d4586055e949062a5f5be141007ef58c.zip |
Updated
Diffstat (limited to 'examples/client.rs')
-rw-r--r-- | examples/client.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/client.rs b/examples/client.rs index ba8c1de..c2dc89f 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -18,10 +18,26 @@ fn main() { drop(args); let mut connection = IrcClient::connect(host.as_slice(), port, "rusty-irc".to_string(), "dremann".to_string(), "Zachary Dremann".to_string()).unwrap(); + let sender = connection.sender(); let on_msg = |message: &Message| { println!("{}", *message); }; + + spawn(proc() { + let mut stdin = stdio::stdin(); + for line in stdin.lines() { + match line { + Ok(s) => { + match from_str(s.as_slice()) { + Some(msg) => sender.send(msg), + None => () + } + } + Err(_) => break, + } + } + }); connection.run_loop(on_msg); } |