Fixing issues
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ use session_rs::session::Session;
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> session_rs::Result<()> {
|
||||
let session = Arc::new(Session::new_server("127.0.0.1:8080", "/").await?);
|
||||
let session = Arc::new(Session::connect("127.0.0.1:8080", "/").await?);
|
||||
|
||||
// Spawn read loop
|
||||
let read_session = Arc::clone(&session);
|
||||
@@ -27,7 +27,7 @@ async fn main() -> session_rs::Result<()> {
|
||||
for i in 0..5 {
|
||||
let msg = serde_json::json!({ "hello": i });
|
||||
session.send(&msg).await?;
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1000)).await;
|
||||
}
|
||||
|
||||
session.close().await?;
|
||||
|
||||
+5
-2
@@ -14,7 +14,7 @@ async fn main() -> session_rs::Result<()> {
|
||||
|
||||
tokio::spawn(async move {
|
||||
// Wrap session in Arc so tasks can share it
|
||||
let session = match Session::new_client(stream).await {
|
||||
let session = match Session::handshake(stream).await {
|
||||
Ok(s) => Arc::new(s),
|
||||
Err(e) => {
|
||||
eprintln!("Handshake failed: {:?}", e);
|
||||
@@ -51,7 +51,10 @@ async fn main() -> session_rs::Result<()> {
|
||||
}
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(_) => break, // connection closed
|
||||
Err(e) => {
|
||||
eprintln!("{e:?}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user