Using the ezsockets call methods to shoot text at the websocket.

This commit is contained in:
Dave Hrycyszyn
2024-06-11 18:29:02 +01:00
parent b1daec3b84
commit 014462c187
3 changed files with 18 additions and 40 deletions

View File

@@ -37,30 +37,21 @@ async fn main() {
/// Wire everything up outside the application so we can test more easily later
async fn setup(name: &String) -> SideNode {
// First, load up the keys and create a bft-crdt
let side_dir = utils::home(name);
let keys = keys::load_from_file(side_dir);
let crdt = BaseCrdt::<TransactionList>::new(&keys);
// Channels for internal communication, and a tokio task for stdin input
let (incoming_sender, incoming_receiver) = mpsc::channel::<SignedOp>(32);
let (stdin_sender, stdin_receiver) = std::sync::mpsc::channel();
let (network_sender, network_receiver) = mpsc::channel::<SignedOp>(32);
task::spawn(async move {
stdin_input(stdin_sender);
});
let crdt = BaseCrdt::<TransactionList>::new(&keys);
let node = SideNode::new(
crdt,
keys,
incoming_receiver,
stdin_receiver,
network_sender,
);
tokio::spawn(async move {
let handle = WebSocketClient::new(incoming_sender, network_receiver).await;
handle.call("start".to_string()).unwrap();
});
// Finally, create the node and return it
let handle = WebSocketClient::new(incoming_sender).await;
let node = SideNode::new(crdt, keys, incoming_receiver, stdin_receiver, handle);
println!("Node setup complete.");
node
}