aboutsummaryrefslogtreecommitdiffstats
path: root/lampada/src/connection/write.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lampada/src/connection/write.rs')
-rw-r--r--lampada/src/connection/write.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/lampada/src/connection/write.rs b/lampada/src/connection/write.rs
index 8f0c34b..1070cdf 100644
--- a/lampada/src/connection/write.rs
+++ b/lampada/src/connection/write.rs
@@ -1,7 +1,9 @@
use std::ops::{Deref, DerefMut};
use luz::{connection::Tls, jabber_stream::bound_stream::BoundJabberWriter};
-use stanza::client::Stanza;
+use stanza::{
+ client::Stanza, stream::Error as StreamErrorStanza, stream_error::Error as StreamError,
+};
use tokio::{
sync::{mpsc, oneshot},
task::JoinHandle,
@@ -34,7 +36,7 @@ pub struct WriteMessage {
pub enum WriteControl {
Disconnect,
- Abort(oneshot::Sender<WriteState>),
+ Abort(Option<StreamError>, oneshot::Sender<WriteState>),
}
impl Write {
@@ -119,7 +121,13 @@ impl Write {
break;
},
// in case of abort, stream is already fucked, just send the receiver ready for a reconnection at the same resource
- WriteControl::Abort(sender) => {
+ WriteControl::Abort(error, sender) => {
+ // write stream error message for server if there is one
+ if let Some(error) = error {
+ // TODO: timeouts for writing to stream
+ let _ = self.stream.write(&Stanza::Error(StreamErrorStanza { error, text: None })).await;
+ // don't care about result, if it sends it sends, otherwise stream is restarting anyway
+ }
let _ = sender.send(WriteState { stanza_recv: self.stanza_receiver });
break;
},