tokio-xmpp: name Event::Online fields, add resumed flag
This commit is contained in:
parent
f8cb643590
commit
4d24e6bebb
2 changed files with 18 additions and 4 deletions
|
@ -193,7 +193,10 @@ impl Stream for Client {
|
|||
Poll::Ready(Ok(Ok(stream))) => {
|
||||
let bound_jid = stream.jid.clone();
|
||||
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))) => {
|
||||
self.state = ClientState::Disconnected;
|
||||
|
|
|
@ -5,7 +5,18 @@ use xmpp_parsers::{Element, Jid};
|
|||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
/// 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
|
||||
Disconnected(Error),
|
||||
/// Received stanza/nonza
|
||||
|
@ -16,7 +27,7 @@ impl Event {
|
|||
/// `Online` event?
|
||||
pub fn is_online(&self) -> bool {
|
||||
match *self {
|
||||
Event::Online(_) => true,
|
||||
Event::Online { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +35,7 @@ impl Event {
|
|||
/// Get the server-assigned JID for the `Online` event
|
||||
pub fn get_jid(&self) -> Option<&Jid> {
|
||||
match *self {
|
||||
Event::Online(ref jid) => Some(jid),
|
||||
Event::Online { ref bound_jid, .. } => Some(bound_jid),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue