tokio-xmpp: name Event::Online fields, add resumed flag

This commit is contained in:
Astro 2020-03-17 22:39:23 +01:00
parent f8cb643590
commit 4d24e6bebb
2 changed files with 18 additions and 4 deletions

View file

@ -193,7 +193,10 @@ impl Stream for Client {
Poll::Ready(Ok(Ok(stream))) => { Poll::Ready(Ok(Ok(stream))) => {
let bound_jid = stream.jid.clone(); let bound_jid = stream.jid.clone();
self.state = ClientState::Connected(stream); self.state = ClientState::Connected(stream);
Poll::Ready(Some(Event::Online(bound_jid))) Poll::Ready(Some(Event::Online {
bound_jid,
resumed: false,
}))
} }
Poll::Ready(Ok(Err(e))) => { Poll::Ready(Ok(Err(e))) => {
self.state = ClientState::Disconnected; self.state = ClientState::Disconnected;

View file

@ -5,7 +5,18 @@ use xmpp_parsers::{Element, Jid};
#[derive(Debug)] #[derive(Debug)]
pub enum Event { pub enum Event {
/// Stream is connected and initialized /// Stream is connected and initialized
Online(Jid), Online {
/// Server-set Jabber-Id for your session
///
/// This may turn out to be a different JID resource than
/// expected, so use this one instead of the JID with which
/// the connection was setup.
bound_jid: Jid,
/// Was this session resumed?
///
/// Not yet implemented for the Client
resumed: bool,
},
/// Stream end /// Stream end
Disconnected(Error), Disconnected(Error),
/// Received stanza/nonza /// Received stanza/nonza
@ -16,7 +27,7 @@ impl Event {
/// `Online` event? /// `Online` event?
pub fn is_online(&self) -> bool { pub fn is_online(&self) -> bool {
match *self { match *self {
Event::Online(_) => true, Event::Online { .. } => true,
_ => false, _ => false,
} }
} }
@ -24,7 +35,7 @@ impl Event {
/// Get the server-assigned JID for the `Online` event /// Get the server-assigned JID for the `Online` event
pub fn get_jid(&self) -> Option<&Jid> { pub fn get_jid(&self) -> Option<&Jid> {
match *self { match *self {
Event::Online(ref jid) => Some(jid), Event::Online { ref bound_jid, .. } => Some(bound_jid),
_ => None, _ => None,
} }
} }