2026-05-25 18:50:40 +02:00
|
|
|
use logos_chat::{ChatClient, ConversationIdOwned, Event, InProcessDelivery};
|
2026-04-08 23:15:48 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let delivery = InProcessDelivery::new(Default::default());
|
|
|
|
|
let mut cursor = delivery.cursor_at_tail("delivery_address");
|
|
|
|
|
|
|
|
|
|
let mut saro = ChatClient::new("saro", delivery.clone());
|
|
|
|
|
let mut raya = ChatClient::new("raya", delivery);
|
|
|
|
|
|
|
|
|
|
let raya_bundle = raya.create_intro_bundle().unwrap();
|
|
|
|
|
saro.create_conversation(&raya_bundle, b"hello raya")
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
let raw = cursor.next().unwrap();
|
2026-05-25 18:50:40 +02:00
|
|
|
let events = raya.receive(&raw).unwrap();
|
|
|
|
|
let raya_convo_id: ConversationIdOwned = events
|
|
|
|
|
.iter()
|
|
|
|
|
.find_map(|e| match e {
|
|
|
|
|
Event::ConversationStarted { convo_id, .. } => Some(Arc::clone(convo_id)),
|
|
|
|
|
_ => None,
|
|
|
|
|
})
|
|
|
|
|
.expect("expected ConversationStarted");
|
|
|
|
|
for event in &events {
|
|
|
|
|
if let Event::MessageReceived { content, .. } = event {
|
|
|
|
|
println!("Raya received: {:?}", std::str::from_utf8(content).unwrap());
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-08 23:15:48 +02:00
|
|
|
|
|
|
|
|
raya.send_message(&raya_convo_id, b"hi saro").unwrap();
|
|
|
|
|
|
|
|
|
|
let raw = cursor.next().unwrap();
|
2026-05-25 18:50:40 +02:00
|
|
|
let events = saro.receive(&raw).unwrap();
|
|
|
|
|
for event in &events {
|
|
|
|
|
if let Event::MessageReceived { content, .. } = event {
|
|
|
|
|
println!("Saro received: {:?}", std::str::from_utf8(content).unwrap());
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-08 23:15:48 +02:00
|
|
|
|
|
|
|
|
println!("Message exchange complete.");
|
|
|
|
|
}
|