mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
implement a part of Client
This commit is contained in:
parent
9c035af4a3
commit
bf7112ff39
2 changed files with 41 additions and 5 deletions
|
@ -1,11 +1,46 @@
|
|||
use jid::Jid;
|
||||
use transport::SslTransport;
|
||||
use error::Error;
|
||||
|
||||
pub struct XmppClient {
|
||||
pub struct ClientBuilder {
|
||||
jid: Jid,
|
||||
host: Option<String>,
|
||||
port: u16,
|
||||
}
|
||||
|
||||
impl ClientBuilder {
|
||||
pub fn new(jid: Jid) -> ClientBuilder {
|
||||
ClientBuilder {
|
||||
jid: jid,
|
||||
host: None,
|
||||
port: 5222,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn host(mut self, host: String) -> ClientBuilder {
|
||||
self.host = Some(host);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn port(mut self, port: u16) -> ClientBuilder {
|
||||
self.port = port;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn connect(self) -> Result<Client, Error> {
|
||||
let host = &self.host.unwrap_or(self.jid.domain.clone());
|
||||
let transport = SslTransport::connect(host, self.port)?;
|
||||
Ok(Client {
|
||||
jid: self.jid,
|
||||
transport: transport
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Client {
|
||||
jid: Jid,
|
||||
transport: SslTransport,
|
||||
}
|
||||
|
||||
impl XmppClient {
|
||||
pub fn connect(jid: Jid) -> XmppClient {
|
||||
unimplemented!();
|
||||
}
|
||||
impl Client {
|
||||
}
|
||||
|
|
|
@ -5,3 +5,4 @@ pub mod ns;
|
|||
pub mod transport;
|
||||
pub mod error;
|
||||
pub mod jid;
|
||||
pub mod client;
|
||||
|
|
Loading…
Reference in a new issue