diff --git a/src/client.rs b/src/client.rs index d5ca481..4488e5d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -148,6 +148,10 @@ impl EppClient { GreetingDocument::deserialize(&self.connection.greeting).map(|obj| obj.data) } + pub async fn reconnect(&mut self) -> Result<(), Error> { + self.connection.reconnect().await + } + pub async fn shutdown(mut self) -> Result<(), Error> { self.connection.shutdown().await } diff --git a/src/connection.rs b/src/connection.rs index 490e5a8..e92f7c6 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -14,6 +14,7 @@ use crate::error::Error; /// EPP Connection struct with some metadata for the connection pub(crate) struct EppConnection { registry: String, + connector: C, stream: C::Connection, pub greeting: String, timeout: Duration, @@ -28,6 +29,7 @@ impl EppConnection { let mut this = Self { registry, stream: connector.connect(timeout).await?, + connector, greeting: String::new(), timeout, }; @@ -88,6 +90,12 @@ impl EppConnection { Ok(String::from_utf8(buf)?) } + pub(crate) async fn reconnect(&mut self) -> Result<(), Error> { + self.stream = self.connector.connect(self.timeout).await?; + self.greeting = self.get_epp_response().await?; + Ok(()) + } + /// Sends an EPP XML request to the registry and return the response /// receieved to the request pub(crate) async fn transact(&mut self, content: &str) -> Result {