Send ping XEP-0199
[?]
Mar 8, 2019, 8:34 PM
5GINRCKLDLAQ7J32MLENDUBXZTVSLGPJFARMHUPKSRXVBT75BG3QCDependencies
- [2]
DISBBP3IUpdate dependencies - [3]
HU3NZX5ZProcess self-presence via new processing code - [4]
X6L47BHQUse different structure for established xmpp connection - [5]
WBU7UOQWRead chatroom from config - [6]
5IKA4GO7Rename xmpp client field from "inner" to "client" - [7]
OGMBXBKPMove online to XmppConnection - [8]
ACXUIS63Update dependecies - [9]
IK3YDPTYUpdate deps - [10]
V5HDBSZMUse jid for receiver address - [11]
RGOSS73UConvert self-presence to xmpp_parser's type - [12]
AA2ZWGRLEnter to MUC - [13]
VS6AHRWIMove XMPP to separate dir - [14]
FVVPKFTLInitial commit - [15]
EOHEZXX3Move request processing to structure - [16]
NDDQQP2PUpdate deps - [17]
VW7NVWAGLeave MUC properly - [18]
QYY3KRGLUse failure instead Box<dyn Error> - [19]
2VZBEEXAMessages fixed - [20]
5OBTKGDLUpdate deps - [21]
37OMJ4CKSend MUC message - [22]
5Y6YJ6UHAdd shutdown function to make actions before offline - [23]
L3D22A5JPrepare to check incoming presence - [24]
YZVEEOYTUpdate dependencies - [25]
ZI4GJ72VAdd message to xmpp command - [26]
OB3HA2MDUse Client::new_with_jid to parse jid only once - [27]
J7VX56FWToDo - [28]
AYQZ2UIAUpdate deps - [*]
FV6BJ5K6Send self-presence and store account info in Rc so it willbe used in some future in parallel - [*]
HKSQO7JZEnable hyper http server and configuration
Change contents
- edit in src/xmpp/stanzas.rs at line 4
use xmpp_parsers::ping::Ping; - edit in src/xmpp/stanzas.rs at line 68
}pub fn make_muc_presence_leave(from: xmpp_parsers::Jid, to: xmpp_parsers::Jid) -> Element {let mut presence = Presence::new(PresenceType::Unavailable);presence.from = Some(from);presence.to = Some(to);presence.into()}pub fn make_ping(id: &str, from: xmpp_parsers::Jid) -> Element {let mut ping = Iq::from_get(Ping);ping.id = Some(id.to_string());ping.to = Some(from.clone().into_domain_jid());ping.from = Some(from);ping.into() - edit in src/xmpp/mod.rs at line 614
XmppCommand::Ping => {self.state.data.counter += 1;let id_ping = format!("id_ping{}", self.state.data.counter);let ping = stanzas::make_ping(&id_ping, self.state.client.jid.clone());self.state.data.send_queue.push_back(ping);} - edit in src/xmpp/mod.rs at line 621
}fn shutdown(self) -> impl Future<Item = (), Error = failure::Error> {info!("Shutdown connection");let XmppConnection { account, state } = self;stream::iter_ok(state.data.mucs.values().map(std::clone::Clone::clone).collect::<Vec<_>>(),).fold(state, move |XmppState { client, data }, muc_jid| {let muc_presence =stanzas::make_muc_presence_leave(account.jid.clone(), muc_jid.clone());info!("Sending muc leave presence... {:?}", muc_presence);use tokio::prelude::Sink;client.send(Packet::Stanza(muc_presence)).map_err(|e| {error!("Error on send muc presence: {}", e);e}).and_then(|client| future::ok(XmppState { client, data }))}).map(|_| ()) - edit in src/xmpp/mod.rs at line 707
Ping, - replacement in src/xmpp/mod.rs at line 757
future::err(format_err!("Command receiver is gone"))error!("Command receiver is gone");future::ok(future::Loop::Break(Some(conn))) - replacement in src/xmpp/mod.rs at line 771
future::ok(future::Loop::Break(()))future::ok(future::Loop::Break(Some(conn))) - replacement in src/xmpp/mod.rs at line 774
Err(_) => future::err(format_err!("Command receiver is broken")),Err(_) => {error!("Command receiver is broken");future::ok(future::Loop::Break(Some(conn)))} - replacement in src/xmpp/mod.rs at line 800
future::ok(future::Loop::Break(()))future::ok(future::Loop::Break(None)) - edit in src/xmpp/mod.rs at line 808
.and_then(|opt_conn| {if let Some(conn) = opt_conn {Box::new(conn.shutdown()) as Box<dyn Future<Item = (), Error = _>>} else {Box::new(future::ok(()))}}) - replacement in src/main.rs at line 67[2.414]→[3.14673:14764](∅→∅),[3.14673]→[3.14673:14764](∅→∅),[3.14764]→[2.415:478](∅→∅),[2.478]→[3.14844:14867](∅→∅),[3.14844]→[3.14844:14867](∅→∅)
.and_then(|s| {std::str::FromStr::from_str(s).map_err(std::convert::Into::into)}).and_then(|s| std::str::FromStr::from_str(s).map_err(std::convert::Into::into)) - replacement in src/main.rs at line 229
.serve(MakeServiceCmd { cmd_send }).serve(MakeServiceCmd {cmd_send: cmd_send.clone(),}) - edit in src/main.rs at line 237
if let Some(ping) = config.account.ping {let ping = tokio::timer::Interval::new_interval(std::time::Duration::from_secs(ping));rt.spawn(ping.map_err(|e| {error!("Ping error: {}", e);}).for_each(move |_| {cmd_send.clone().send(XmppCommand::Ping).map_err(|e| {error!("Ping command error: {}", e);}).map(|_| ())}).select(ctrl_c.clone().map(|_| ()).map_err(|e| error!("ping server error: {}", e)),).map(|_| ()).map_err(|_| ()),);} - edit in src/config.rs at line 0[31.1396][31.1397]
use std::collections::HashMap; - edit in src/config.rs at line 10[31.1549][31.1549]
#[serde(default, deserialize_with = "deserialize_jid_map")]pub chatrooms: HashMap<String, xmpp_parsers::Jid>,pub ping: Option<u64>, - edit in src/config.rs at line 39[3.19119][31.1943]
}fn deserialize_jid_map<'de, D>(deserializer: D,) -> Result<HashMap<String, xmpp_parsers::Jid>, D::Error>whereD: serde::Deserializer<'de>,{use serde::Deserialize;let s = HashMap::<String, String>::deserialize(deserializer)?;let size = s.len();s.into_iter().map(|(k, v)| (k, std::str::FromStr::from_str(&v))).take_while(|(_k, r)| r.is_ok()).fold(Ok(HashMap::with_capacity(size)), |res, (k, r)| match res {Ok(mut res) => match r {Ok(v) => {res.insert(k, v);Ok(res)}Err(e) => Err(e),},Err(e) => Err(e),}).map_err(serde::de::Error::custom) - replacement in Cargo.lock at line 7
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 44
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 61
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 73
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 131
version = "0.4.12"version = "0.4.11" - replacement in Cargo.lock at line 150
version = "0.1.7"version = "0.1.6" - replacement in Cargo.lock at line 191
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 199
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 217
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 237
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 273
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 278
version = "0.6.1"version = "0.6.0" - replacement in Cargo.lock at line 312
"syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)","syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 395
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 420
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 429
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 452
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 494
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 551
version = "0.2.50"version = "0.2.49" - replacement in Cargo.lock at line 573
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 639
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 653
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 674
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 690
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 723
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 737
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 740
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 755
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 783
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 892
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 903
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 909
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)","rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 958
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 965
version = "0.1.3"version = "0.1.2" - replacement in Cargo.lock at line 970
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1077
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)","rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1103
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1114
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1135
"env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)","env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1163
"syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)","syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1216
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1239
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1308
version = "0.15.28"version = "0.15.27" - replacement in Cargo.lock at line 1331
"syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)","syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1340
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1371
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1397
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1407
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1438
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1476
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1505
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1529
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1579
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1593
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1596
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1610
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)","bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1663
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1686
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)","cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - replacement in Cargo.lock at line 1891
"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c""checksum bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "40ade3d27603c2cb345eb0912aec461a6dec7e06a4ae48589904e808335c7afa" - replacement in Cargo.lock at line 1894
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4""checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" - replacement in Cargo.lock at line 1908
"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a""checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" - replacement in Cargo.lock at line 1940
"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1""checksum libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)" = "413f3dfc802c5dc91dc570b05125b6cda9855edfaa9825c9849807876376e70e" - replacement in Cargo.lock at line 1989
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071""checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" - replacement in Cargo.lock at line 2028
"checksum syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)" = "218aa5a01ab9805df6e9e48074c8d88f317cc9660b1ad6c3dabac2d627d185d6""checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec"