diff options
author | 2025-03-26 15:57:24 +0000 | |
---|---|---|
committer | 2025-03-26 15:57:24 +0000 | |
commit | 521a8915f273dc2cda59080a2393e40e4f25db50 (patch) | |
tree | 5fd01f240084566bb8d32261819f7ab14022346e /filamento/examples | |
parent | 4d1be876f8bccf8018728d5ee474f91c256da5c9 (diff) | |
download | luz-521a8915f273dc2cda59080a2393e40e4f25db50.tar.gz luz-521a8915f273dc2cda59080a2393e40e4f25db50.tar.bz2 luz-521a8915f273dc2cda59080a2393e40e4f25db50.zip |
feat(filamento): create example
Diffstat (limited to 'filamento/examples')
-rw-r--r-- | filamento/examples/example.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/filamento/examples/example.rs b/filamento/examples/example.rs new file mode 100644 index 0000000..f2b787b --- /dev/null +++ b/filamento/examples/example.rs @@ -0,0 +1,35 @@ +use std::{path::Path, str::FromStr, time::Duration}; + +use filamento::{Client, db::Db}; +use jid::JID; +use tracing::info; + +#[tokio::main] +async fn main() { + tracing_subscriber::fmt::init(); + let db = Db::create_connect_and_migrate(Path::new("./filamentoa.db")) + .await + .unwrap(); + let (client, mut recv) = + Client::new("test@blos.sm".try_into().unwrap(), "slayed".to_string(), db); + + tokio::spawn(async move { + while let Some(msg) = recv.recv().await { + info!("{:#?}", msg) + } + }); + + client.connect().await.unwrap(); + tokio::time::sleep(Duration::from_secs(5)).await; + info!("sending message"); + client + .send_message( + JID::from_str("cel@blos.sm").unwrap(), + filamento::chat::Body { + body: "hallo!!!".to_string(), + }, + ) + .await + .unwrap(); + println!("sent message"); +} |