Going back to blocking, need a new thread here

This commit is contained in:
Dave Hrycyszyn
2024-06-10 14:26:00 +01:00
parent 4717ffa7e8
commit 91fbe7f9bd

View File

@@ -1,8 +1,7 @@
use async_trait::async_trait; use async_trait::async_trait;
use bft_json_crdt::json_crdt::SignedOp; use bft_json_crdt::json_crdt::SignedOp;
use ezsockets::ClientConfig; use ezsockets::ClientConfig;
use tokio::fs::File; use std::io::BufRead;
use tokio::io;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use crate::{node::SideNode, utils}; use crate::{node::SideNode, utils};
@@ -25,23 +24,23 @@ impl WebSocketClient {
tokio::spawn(async move { tokio::spawn(async move {
future.await.unwrap(); future.await.unwrap();
}); });
let stdin = tokio::io::stdin(); let stdin = std::io::stdin();
// let lines = stdin.lock().lines(); let lines = stdin.lock().lines();
// for line in lines {
let mut reader = FramedRead::new(stdin, LinesCodec::new()); let line = line.unwrap();
let line = reader.next().await.transpose()?.unwrap(); let signed_op = if let "exit" = line.as_str() {
let signed_op = if let "exit" = line.as_str() { break;
break; } else if let "trace" = line.as_str() {
} else if let "trace" = line.as_str() { node.trace_crdt();
node.trace_crdt(); continue;
continue; } else {
} else { let fake = utils::fake_transaction("foo123".to_string());
let fake = utils::fake_transaction("foo123".to_string()); node.add_transaction_local(fake)
node.add_transaction_local(fake) };
}; tracing::info!("sending {:?}", signed_op);
tracing::info!("sending {:?}", signed_op); let json = serde_json::to_string(&signed_op).unwrap();
let json = serde_json::to_string(&signed_op).unwrap(); handle.text(json).unwrap();
handle.text(json).unwrap(); }
} }
} }