Added some documentation to the reactor examples.

This commit is contained in:
Aaron Weiss 2018-01-24 12:28:07 +01:00
parent fbe17978fc
commit 495e419de0
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF
2 changed files with 7 additions and 0 deletions

View file

@ -24,11 +24,16 @@ fn main() {
let mut reactor = IrcReactor::new().unwrap();
for config in configs {
// Immediate errors like failure to resolve the server's name or to establish any connection will
// manifest here in the result of prepare_server_and_connect.
let server = reactor.prepare_server_and_connect(&config).unwrap();
server.identify().unwrap();
// Here, we tell the reactor to setup this server for future handling (in run) using the specified
// handler function process_msg.
reactor.register_server_with_handler(server, process_msg);
}
// Runtime errors like a dropped connection will manifest here in the result of run.
reactor.run().unwrap();
}

View file

@ -36,7 +36,9 @@ fn main() {
}).and_then(|()| reactor.run());
match res {
// The connections ended normally (for example, they sent a QUIT message to the server).
Ok(_) => break,
// Something went wrong! We'll print the error, and restart the connections.
Err(e) => eprintln!("{}", e),
}
}