aboutsummaryrefslogtreecommitdiffstats
path: root/lampada/src/connection
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-26 14:29:40 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-26 14:29:40 +0000
commit2211f324782cdc617b4b5ecd071178e372539fe4 (patch)
treea5ea5ce11d748424447dee23173d3cb8aec648ea /lampada/src/connection
parent2f8671978e18c1e1e7834056ae674f32fbde3868 (diff)
downloadluz-2211f324782cdc617b4b5ecd071178e372539fe4.tar.gz
luz-2211f324782cdc617b4b5ecd071178e372539fe4.tar.bz2
luz-2211f324782cdc617b4b5ecd071178e372539fe4.zip
refactor: rename crates and move client logic to separate crate `filament`
Diffstat (limited to '')
-rw-r--r--lampada/src/connection/mod.rs (renamed from luz/src/connection/mod.rs)19
-rw-r--r--lampada/src/connection/read.rs (renamed from luz/src/connection/read.rs)15
-rw-r--r--lampada/src/connection/write.rs (renamed from luz/src/connection/write.rs)2
3 files changed, 14 insertions, 22 deletions
diff --git a/luz/src/connection/mod.rs b/lampada/src/connection/mod.rs
index 288de70..1e767b0 100644
--- a/luz/src/connection/mod.rs
+++ b/lampada/src/connection/mod.rs
@@ -7,8 +7,8 @@ use std::{
time::Duration,
};
-use jabber::{connection::Tls, jabber_stream::bound_stream::BoundJabberStream};
use jid::JID;
+use luz::{connection::Tls, jabber_stream::bound_stream::BoundJabberStream};
use read::{ReadControl, ReadControlHandle, ReadState};
use stanza::client::Stanza;
use tokio::{
@@ -19,9 +19,8 @@ use tracing::info;
use write::{WriteControl, WriteControlHandle, WriteHandle, WriteMessage, WriteState};
use crate::{
- db::Db,
- error::{ConnectionError, Error, ReadError, WriteError},
- Connected, Logic, LogicState, UpdateMessage,
+ error::{ConnectionError, WriteError},
+ Connected, Logic,
};
mod read;
@@ -84,7 +83,9 @@ impl<Lgc: Logic + Clone + Send + 'static> Supervisor<Lgc> {
match msg {
SupervisorCommand::Disconnect => {
info!("disconnecting");
- // TODO: do handle_disconnect here
+ self.logic
+ .handle_disconnect(self.connected.clone())
+ .await;
let _ = self.write_control_handle.send(WriteControl::Disconnect).await;
let _ = self.read_control_handle.send(ReadControl::Disconnect).await;
info!("sent disconnect command");
@@ -108,11 +109,11 @@ impl<Lgc: Logic + Clone + Send + 'static> Supervisor<Lgc> {
// send abort to read stream, as already done, consider
let (read_state, mut write_state);
match state {
- // TODO: proper state things for read and write thread
ChildState::Write(receiver) => {
write_state = receiver;
let (send, recv) = oneshot::channel();
let _ = self.read_control_handle.send(ReadControl::Abort(send)).await;
+ // TODO: need a tokio select, in case the state arrives from somewhere else
if let Ok(state) = recv.await {
read_state = state;
} else {
@@ -135,7 +136,7 @@ impl<Lgc: Logic + Clone + Send + 'static> Supervisor<Lgc> {
let mut jid = self.connected.jid.clone();
let mut domain = jid.domainpart.clone();
// TODO: make sure connect_and_login does not modify the jid, but instead returns a jid. or something like that
- let connection = jabber::connect_and_login(&mut jid, &*self.password, &mut domain).await;
+ let connection = luz::connect_and_login(&mut jid, &*self.password, &mut domain).await;
match connection {
Ok(c) => {
let (read, write) = c.split();
@@ -182,7 +183,7 @@ impl<Lgc: Logic + Clone + Send + 'static> Supervisor<Lgc> {
let mut jid = self.connected.jid.clone();
let mut domain = jid.domainpart.clone();
// TODO: same here
- let connection = jabber::connect_and_login(&mut jid, &*self.password, &mut domain).await;
+ let connection = luz::connect_and_login(&mut jid, &*self.password, &mut domain).await;
match connection {
Ok(c) => {
let (read, write) = c.split();
@@ -226,7 +227,7 @@ impl<Lgc: Logic + Clone + Send + 'static> Supervisor<Lgc> {
let mut jid = self.connected.jid.clone();
let mut domain = jid.domainpart.clone();
- let connection = jabber::connect_and_login(&mut jid, &*self.password, &mut domain).await;
+ let connection = luz::connect_and_login(&mut jid, &*self.password, &mut domain).await;
match connection {
Ok(c) => {
let (read, write) = c.split();
diff --git a/luz/src/connection/read.rs b/lampada/src/connection/read.rs
index 4e55bc5..cc69387 100644
--- a/luz/src/connection/read.rs
+++ b/lampada/src/connection/read.rs
@@ -7,24 +7,15 @@ use std::{
time::Duration,
};
-use chrono::{DateTime, Utc};
-use jabber::{connection::Tls, jabber_stream::bound_stream::BoundJabberReader};
+use luz::{connection::Tls, jabber_stream::bound_stream::BoundJabberReader};
use stanza::client::Stanza;
use tokio::{
sync::{mpsc, oneshot, Mutex},
task::{JoinHandle, JoinSet},
};
use tracing::info;
-use uuid::Uuid;
-
-use crate::{
- chat::{Body, Message},
- db::Db,
- error::{Error, IqError, MessageRecvError, PresenceError, ReadError, RosterError},
- presence::{Offline, Online, Presence, PresenceType, Show},
- roster::Contact,
- Connected, Logic, LogicState, UpdateMessage,
-};
+
+use crate::{Connected, Logic};
use super::{write::WriteHandle, SupervisorCommand, SupervisorSender};
diff --git a/luz/src/connection/write.rs b/lampada/src/connection/write.rs
index ff78b81..8f0c34b 100644
--- a/luz/src/connection/write.rs
+++ b/lampada/src/connection/write.rs
@@ -1,6 +1,6 @@
use std::ops::{Deref, DerefMut};
-use jabber::{connection::Tls, jabber_stream::bound_stream::BoundJabberWriter};
+use luz::{connection::Tls, jabber_stream::bound_stream::BoundJabberWriter};
use stanza::client::Stanza;
use tokio::{
sync::{mpsc, oneshot},