echo_bot: take jid, password from cmdline args
This commit is contained in:
parent
6e5f86632f
commit
fa08591162
1 changed files with 12 additions and 2 deletions
|
@ -4,15 +4,25 @@ extern crate tokio_xmpp;
|
||||||
extern crate jid;
|
extern crate jid;
|
||||||
extern crate xml;
|
extern crate xml;
|
||||||
|
|
||||||
|
use std::env::args;
|
||||||
|
use std::process::exit;
|
||||||
use tokio_core::reactor::Core;
|
use tokio_core::reactor::Core;
|
||||||
use futures::{Future, Stream, Sink, future};
|
use futures::{Future, Stream, Sink, future};
|
||||||
use tokio_xmpp::Client;
|
use tokio_xmpp::Client;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Tokio_core context
|
let args: Vec<String> = args().collect();
|
||||||
|
if args.len() != 3 {
|
||||||
|
println!("Usage: {} <jid> <password>", args[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
let jid = &args[1];
|
||||||
|
let password = &args[2];
|
||||||
|
|
||||||
|
// tokio_core context
|
||||||
let mut core = Core::new().unwrap();
|
let mut core = Core::new().unwrap();
|
||||||
// Client instance
|
// Client instance
|
||||||
let client = Client::new("astrobot@example.org", "", &core.handle()).unwrap();
|
let client = Client::new(jid, password, core.handle()).unwrap();
|
||||||
|
|
||||||
// Make the two interfaces for sending and receiving independent
|
// Make the two interfaces for sending and receiving independent
|
||||||
// of each other so we can move one into a closure.
|
// of each other so we can move one into a closure.
|
||||||
|
|
Loading…
Reference in a new issue