Added some documentation to the reactor examples.
This commit is contained in:
parent
fbe17978fc
commit
495e419de0
2 changed files with 7 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue