diff options
author | 2025-03-26 14:29:40 +0000 | |
---|---|---|
committer | 2025-03-26 14:29:40 +0000 | |
commit | 2211f324782cdc617b4b5ecd071178e372539fe4 (patch) | |
tree | a5ea5ce11d748424447dee23173d3cb8aec648ea /lampada/src/main.rs | |
parent | 2f8671978e18c1e1e7834056ae674f32fbde3868 (diff) | |
download | luz-2211f324782cdc617b4b5ecd071178e372539fe4.tar.gz luz-2211f324782cdc617b4b5ecd071178e372539fe4.tar.bz2 luz-2211f324782cdc617b4b5ecd071178e372539fe4.zip |
refactor: rename crates and move client logic to separate crate `filament`
Diffstat (limited to 'lampada/src/main.rs')
-rw-r--r-- | lampada/src/main.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lampada/src/main.rs b/lampada/src/main.rs new file mode 100644 index 0000000..7b7469d --- /dev/null +++ b/lampada/src/main.rs @@ -0,0 +1,42 @@ +use std::{path::Path, str::FromStr, time::Duration}; + +use jid::JID; +use lampada::{db::Db, CoreClientCommand, LuzHandle}; +use sqlx::SqlitePool; +use tokio::{ + io::{AsyncReadExt, AsyncWriteExt}, + sync::oneshot, +}; +use tracing::info; + +#[tokio::main] +async fn main() { + tracing_subscriber::fmt::init(); + let db = Db::create_connect_and_migrate(Path::new("./luz.db")) + .await + .unwrap(); + let (luz, mut recv) = + LuzHandle::new("test@blos.sm".try_into().unwrap(), "slayed".to_string(), db); + + tokio::spawn(async move { + while let Some(msg) = recv.recv().await { + info!("{:#?}", msg) + } + }); + + luz.send(CoreClientCommand::Connect).await.unwrap(); + let (send, recv) = oneshot::channel(); + tokio::time::sleep(Duration::from_secs(5)).await; + info!("sending message"); + luz.send(CoreClientCommand::SendMessage( + JID::from_str("cel@blos.sm").unwrap(), + luz::chat::Body { + body: "hallo!!!".to_string(), + }, + send, + )) + .await + .unwrap(); + recv.await.unwrap().unwrap(); + println!("sent message"); +} |