Simplified tweeter example code.

This commit is contained in:
Aaron Weiss 2014-12-11 00:06:12 -05:00
parent 0cf8fd49af
commit eb091a0b58

View file

@ -19,18 +19,10 @@ fn main() {
let irc_server = Arc::new(IrcServer::from_config(config).unwrap()); let irc_server = Arc::new(IrcServer::from_config(config).unwrap());
let irc_server2 = irc_server.clone(); let irc_server2 = irc_server.clone();
// The wrapper provides us with methods like send_privmsg(...) and identify(...) // The wrapper provides us with methods like send_privmsg(...) and identify(...)
let server = Wrapper::new(&*irc_server); let server = Wrapper::new(&*irc_server2);
server.identify().unwrap(); server.identify().unwrap();
// Let's set up a loop that ignores timeouts, and reads perpetually. // Let's set up a loop that just prints the messages.
// n.b. this shouldn't exit automatically if the connection closes. spawn(proc() { irc_server.iter().map(|m| print!("{}", m.into_string())).count(); });
spawn(proc() {
let mut iter = irc_server2.iter();
loop {
if let Some(msg) = iter.next() {
print!("{}", msg.into_string());
}
}
});
loop { loop {
server.send_privmsg("#vana", "TWEET TWEET").unwrap(); server.send_privmsg("#vana", "TWEET TWEET").unwrap();
sleep(Duration::seconds(10)) sleep(Duration::seconds(10))