aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/src/logic/disconnect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'filamento/src/logic/disconnect.rs')
-rw-r--r--filamento/src/logic/disconnect.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/filamento/src/logic/disconnect.rs b/filamento/src/logic/disconnect.rs
new file mode 100644
index 0000000..241c3e6
--- /dev/null
+++ b/filamento/src/logic/disconnect.rs
@@ -0,0 +1,18 @@
+use lampada::Connected;
+use stanza::client::Stanza;
+
+use crate::{UpdateMessage, presence::Offline};
+
+use super::ClientLogic;
+
+pub async fn handle_disconnect(logic: ClientLogic, connection: Connected) {
+ // TODO: be able to set offline status message
+ let offline_presence: stanza::client::presence::Presence = Offline::default().into_stanza(None);
+ let stanza = Stanza::Presence(offline_presence);
+ // TODO: timeout and error check
+ connection.write_handle().write(stanza).await;
+ let _ = logic
+ .update_sender()
+ .send(UpdateMessage::Offline(Offline::default()))
+ .await;
+}