Using the ezsockets call methods to shoot text at the websocket.
This commit is contained in:
@@ -2,14 +2,14 @@ use bft_json_crdt::json_crdt::{BaseCrdt, SignedOp};
|
||||
use fastcrypto::ed25519::Ed25519KeyPair;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::{crdt::TransactionList, utils};
|
||||
use crate::{crdt::TransactionList, utils, websocket::WebSocketClient};
|
||||
|
||||
pub(crate) struct SideNode {
|
||||
crdt: BaseCrdt<TransactionList>,
|
||||
keys: fastcrypto::ed25519::Ed25519KeyPair,
|
||||
incoming_receiver: mpsc::Receiver<SignedOp>,
|
||||
stdin_receiver: std::sync::mpsc::Receiver<String>,
|
||||
network_sender: mpsc::Sender<SignedOp>,
|
||||
handle: ezsockets::Client<WebSocketClient>,
|
||||
}
|
||||
|
||||
impl SideNode {
|
||||
@@ -18,14 +18,14 @@ impl SideNode {
|
||||
keys: Ed25519KeyPair,
|
||||
incoming_receiver: mpsc::Receiver<SignedOp>,
|
||||
stdin_receiver: std::sync::mpsc::Receiver<String>,
|
||||
network_sender: mpsc::Sender<SignedOp>,
|
||||
handle: ezsockets::Client<WebSocketClient>,
|
||||
) -> Self {
|
||||
let node = Self {
|
||||
crdt,
|
||||
keys,
|
||||
incoming_receiver,
|
||||
stdin_receiver,
|
||||
network_sender,
|
||||
handle,
|
||||
};
|
||||
node
|
||||
}
|
||||
@@ -55,7 +55,8 @@ impl SideNode {
|
||||
|
||||
async fn send_to_network(&self, signed_op: SignedOp) {
|
||||
println!("sending to network: {:?}", signed_op);
|
||||
self.network_sender.send(signed_op).await.unwrap();
|
||||
let to_send = serde_json::to_string(&signed_op).unwrap();
|
||||
self.handle.call(to_send).unwrap();
|
||||
}
|
||||
|
||||
fn handle_incoming(&mut self, incoming: &SignedOp) {
|
||||
|
||||
Reference in New Issue
Block a user