diff --git a/src/client/mod.rs b/src/client/mod.rs index 4f31dad0..fab4571c 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -22,8 +22,6 @@ use self::bind::ClientBind; /// XMPP client connection and state pub struct Client { - /// The client's current Jabber-Id - pub jid: Jid, state: ClientState, } @@ -51,9 +49,8 @@ impl Client { /// Start a new client given that the JID is already parsed. pub fn new_with_jid(jid: Jid, password: &str) -> Self { let password = password.to_owned(); - let connect = Self::make_connect(jid.clone(), password.clone()); + let connect = Self::make_connect(jid, password.clone()); let client = Client { - jid, state: ClientState::Connecting(Box::new(connect)), }; client @@ -125,6 +122,15 @@ impl Client { fn bind(stream: xmpp_stream::XMPPStream) -> ClientBind { ClientBind::new(stream) } + + /// Get the client's bound JID (the one reported by the XMPP + /// server). + pub fn bound_jid(&self) -> Option<&Jid> { + match self.state { + ClientState::Connected(ref stream) => Some(&stream.jid), + _ => None, + } + } } impl Stream for Client {