rust-irc/examples/multithreaded.rs

23 lines
634 B
Rust
Raw Normal View History

extern crate irc;
use std::default::Default;
use std::thread::spawn;
2015-02-23 03:22:33 +01:00
use irc::client::prelude::*;
fn main() {
let config = Config {
nickname: Some(format!("pickles")),
server: Some(format!("irc.fyrechat.net")),
channels: Some(vec![format!("#vana")]),
.. Default::default()
};
let server = IrcServer::from_config(config).unwrap();
server.identify().unwrap();
let server = server.clone();
2015-06-22 18:03:57 +02:00
let _ = spawn(move || {
for msg in server.iter() {
2016-03-18 02:39:58 +01:00
print!("{}", msg.unwrap());
}
}).join(); // You might not want to join here for actual multi-threading.
}