Refactored types

This commit is contained in:
2026-02-19 00:23:47 +01:00
parent c5dd9f019d
commit 8d67252800
6 changed files with 76 additions and 59 deletions
+10 -9
View File
@@ -1,6 +1,6 @@
use std::sync::Arc;
use session_rs::{SessionFrame, ws::WebSocket};
use session_rs::ws::{Frame, WebSocket};
#[tokio::main(flavor = "current_thread")]
async fn main() -> session_rs::Result<()> {
@@ -10,13 +10,14 @@ async fn main() -> session_rs::Result<()> {
let read_session = Arc::clone(&session);
tokio::spawn(async move {
loop {
match read_session.read().await {
Ok(SessionFrame::Text(text)) => {
println!("Server says: {}", text);
}
Ok(_) => {}
Err(_) => break,
}
println!("{:?}", read_session.read().await);
// match read_session.read().await {
// Ok(Frame::Text(text)) => {
// println!("Server says: {}", text);
// }
// Ok(_) => {}
// Err(_) => break,
// }
}
});
@@ -24,7 +25,7 @@ async fn main() -> session_rs::Result<()> {
for i in 0..5 {
println!("sending");
let msg = serde_json::json!({ "hello": i });
session.send(&msg).await?;
session.send(&msg.to_string()).await?;
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}