Upgrade deps, specifically tokio-xmpp 3.0.0
This commit is contained in:
parent
5a71229c50
commit
d12a548793
1960
Cargo.lock
generated
1960
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
19
Cargo.toml
19
Cargo.toml
@ -15,14 +15,13 @@ edition = "2018"
|
|||||||
exclude = [ ".gitignore" ]
|
exclude = [ ".gitignore" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
toml = "0.4.10"
|
toml = "0.5"
|
||||||
serde_derive = "1.0.85"
|
serde_derive = "1.0"
|
||||||
serde = "1.0.85"
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
gumdrop = "0.5.0"
|
gumdrop = "0.8.0"
|
||||||
gumdrop_derive = "0.5.0"
|
gumdrop_derive = "0.8.0"
|
||||||
dirs = "1.0.4"
|
dirs = "3.0.1"
|
||||||
tokio-xmpp = "1.0.1"
|
tokio-xmpp = "3.0.0"
|
||||||
futures = "0.1"
|
tokio = { version = "1", features = ["net", "rt", "rt-multi-thread", "macros"] }
|
||||||
tokio = "0.1"
|
xmpp-parsers = "0.18"
|
||||||
xmpp-parsers = "0.15"
|
|
||||||
die = "0.2.0"
|
die = "0.2.0"
|
||||||
|
36
src/main.rs
36
src/main.rs
@ -8,10 +8,7 @@ use die::{die, Die};
|
|||||||
use gumdrop::Options;
|
use gumdrop::Options;
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
|
|
||||||
use futures::{future, Sink, Stream};
|
use tokio_xmpp::SimpleClient as Client;
|
||||||
use tokio::runtime::current_thread::Runtime;
|
|
||||||
use tokio_xmpp::xmpp_codec::Packet;
|
|
||||||
use tokio_xmpp::Client;
|
|
||||||
use xmpp_parsers::message::{Body, Message};
|
use xmpp_parsers::message::{Body, Message};
|
||||||
use xmpp_parsers::{Element, Jid};
|
use xmpp_parsers::{Element, Jid};
|
||||||
|
|
||||||
@ -57,7 +54,8 @@ struct MyOptions {
|
|||||||
attempt_pgp: bool,
|
attempt_pgp: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
let args: Vec<String> = args().collect();
|
let args: Vec<String> = args().collect();
|
||||||
|
|
||||||
// Remember to skip the first argument. That's the program name.
|
// Remember to skip the first argument. That's the program name.
|
||||||
@ -109,36 +107,16 @@ fn main() {
|
|||||||
.die("error reading from stdin");
|
.die("error reading from stdin");
|
||||||
let data = data.trim();
|
let data = data.trim();
|
||||||
|
|
||||||
// tokio_core context
|
|
||||||
let mut rt = Runtime::new().die("unknown error");
|
|
||||||
// Client instance
|
// Client instance
|
||||||
let client = Client::new(&cfg.jid, &cfg.password).die("could not connect to xmpp server");
|
let mut client = Client::new(&cfg.jid, &cfg.password).await.die("could not connect to xmpp server");
|
||||||
|
|
||||||
// Make the two interfaces for sending and receiving independent
|
|
||||||
// of each other so we can move one into a closure.
|
|
||||||
let (sink, stream) = client.split();
|
|
||||||
let mut sink_state = Some(sink);
|
|
||||||
|
|
||||||
// Main loop, processes events
|
|
||||||
let done = stream.for_each(move |event| {
|
|
||||||
if event.is_online() {
|
|
||||||
let mut sink = sink_state.take().die("unknown error");
|
|
||||||
for recipient in recipients {
|
for recipient in recipients {
|
||||||
let reply = make_reply(recipient.clone(), &data);
|
let reply = make_reply(recipient.clone(), &data);
|
||||||
sink.start_send(Packet::Stanza(reply)).die("send failed");
|
client.send_stanza(reply).await.unwrap();
|
||||||
}
|
|
||||||
sink.start_send(Packet::StreamEnd)
|
|
||||||
.die("send stream end failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Box::new(future::ok(()))
|
// Close client connection
|
||||||
});
|
client.end().await.ok(); // ignore errors here, I guess
|
||||||
|
|
||||||
// Start polling `done`
|
|
||||||
match rt.block_on(done) {
|
|
||||||
Ok(_) => (),
|
|
||||||
Err(e) => die!("Fatal: {}", e),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct a chat <message/>
|
// Construct a chat <message/>
|
||||||
|
Loading…
Reference in New Issue
Block a user