tokio_xmpp::AsyncClient and xmpp::Agent take a fully parsed Jid (#72)
This commit is contained in:
parent
7064ef5c17
commit
209bab1441
8 changed files with 56 additions and 36 deletions
|
|
@ -2,13 +2,14 @@ use futures::stream::StreamExt;
|
|||
use std::convert::TryFrom;
|
||||
use std::env::args;
|
||||
use std::process::exit;
|
||||
use std::str::FromStr;
|
||||
use tokio_xmpp::AsyncClient as Client;
|
||||
use xmpp_parsers::{
|
||||
disco::{DiscoInfoQuery, DiscoInfoResult},
|
||||
iq::{Iq, IqType},
|
||||
ns,
|
||||
server_info::ServerInfo,
|
||||
Element, Jid,
|
||||
BareJid, Element, Jid,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -18,12 +19,12 @@ async fn main() {
|
|||
println!("Usage: {} <jid> <password> <target>", args[0]);
|
||||
exit(1);
|
||||
}
|
||||
let jid = &args[1];
|
||||
let jid = BareJid::from_str(&args[1]).expect(&format!("Invalid JID: {}", &args[1]));
|
||||
let password = args[2].clone();
|
||||
let target = &args[3];
|
||||
|
||||
// Client instance
|
||||
let mut client = Client::new(jid, password).unwrap();
|
||||
let mut client = Client::new(jid, password);
|
||||
|
||||
// Main loop, processes events
|
||||
let mut wait_for_stream_end = false;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use xmpp_parsers::{
|
|||
NodeName,
|
||||
},
|
||||
stanza_error::{DefinedCondition, ErrorType, StanzaError},
|
||||
Element, Jid,
|
||||
BareJid, Element, Jid,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -32,11 +32,11 @@ async fn main() {
|
|||
println!("Usage: {} <jid> <password>", args[0]);
|
||||
exit(1);
|
||||
}
|
||||
let jid = &args[1];
|
||||
let jid = BareJid::from_str(&args[1]).expect(&format!("Invalid JID: {}", &args[1]));
|
||||
let password = args[2].clone();
|
||||
|
||||
// Client instance
|
||||
let mut client = Client::new(jid, password).unwrap();
|
||||
let mut client = Client::new(jid.clone(), password);
|
||||
|
||||
let disco_info = make_disco();
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ async fn main() {
|
|||
} else if let IqType::Result(Some(payload)) = iq.payload {
|
||||
if payload.is("pubsub", ns::PUBSUB) {
|
||||
let pubsub = PubSub::try_from(payload).unwrap();
|
||||
let from = iq.from.clone().unwrap_or(Jid::from_str(jid).unwrap());
|
||||
let from = iq.from.clone().unwrap_or(jid.clone().into());
|
||||
handle_iq_result(pubsub, &from);
|
||||
}
|
||||
} else if let IqType::Set(_) = iq.payload {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ use futures::stream::StreamExt;
|
|||
use std::convert::TryFrom;
|
||||
use std::env::args;
|
||||
use std::process::exit;
|
||||
use std::str::FromStr;
|
||||
use tokio;
|
||||
use tokio_xmpp::AsyncClient as Client;
|
||||
use xmpp_parsers::message::{Body, Message, MessageType};
|
||||
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
|
||||
use xmpp_parsers::{Element, Jid};
|
||||
use xmpp_parsers::{BareJid, Element, Jid};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
|
@ -15,11 +16,11 @@ async fn main() {
|
|||
println!("Usage: {} <jid> <password>", args[0]);
|
||||
exit(1);
|
||||
}
|
||||
let jid = &args[1];
|
||||
let jid = BareJid::from_str(&args[1]).expect(&format!("Invalid JID: {}", &args[1]));
|
||||
let password = &args[2];
|
||||
|
||||
// Client instance
|
||||
let mut client = Client::new(jid, password.to_owned()).unwrap();
|
||||
let mut client = Client::new(jid, password.to_owned());
|
||||
client.set_reconnect(true);
|
||||
|
||||
// Main loop, processes events
|
||||
|
|
|
|||
Loading…
Reference in a new issue