Periodic websocket sends are now working
This commit is contained in:
1328
Cargo.lock
generated
1328
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,5 +7,14 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.4", features = ["derive"] }
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
tokio = "*"
|
tokio = { version = "1.37.0", features = ["time"] }
|
||||||
websockets = "0.3.0"
|
websockets = "0.3.0"
|
||||||
|
bft-json-crdt = { path = "../../bft-json-crdt" }
|
||||||
|
bft-crdt-derive = { path = "../../bft-json-crdt/bft-crdt-derive" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["bft", "logging-list", "logging-json"]
|
||||||
|
logging-list = ["logging-base"]
|
||||||
|
logging-json = ["logging-base"]
|
||||||
|
logging-base = []
|
||||||
|
bft = []
|
||||||
|
|||||||
0
side-node/src/crypto/mod.rs
Normal file
0
side-node/src/crypto/mod.rs
Normal file
@@ -1,3 +1,4 @@
|
|||||||
|
use bft_json_crdt::keypair::make_keypair;
|
||||||
use cli::{parse_args, Commands};
|
use cli::{parse_args, Commands};
|
||||||
|
|
||||||
pub(crate) mod cli;
|
pub(crate) mod cli;
|
||||||
@@ -13,7 +14,8 @@ async fn main() {
|
|||||||
init::init();
|
init::init();
|
||||||
}
|
}
|
||||||
Some(Commands::Run {}) => {
|
Some(Commands::Run {}) => {
|
||||||
websocket::start().await.unwrap();
|
let keys = make_keypair();
|
||||||
|
websocket::start(keys).await.unwrap();
|
||||||
}
|
}
|
||||||
None => println!("No command provided. Exiting. See --help for more information."),
|
None => println!("No command provided. Exiting. See --help for more information."),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
|
use bft_json_crdt::keypair::Ed25519KeyPair;
|
||||||
|
use tokio::time::{self};
|
||||||
use websockets::WebSocket;
|
use websockets::WebSocket;
|
||||||
|
|
||||||
pub(crate) async fn start() -> Result<(), websockets::WebSocketError> {
|
/// Starts a websocket and periodically sends a BFT-CRDT message to the websocket server
|
||||||
|
pub(crate) async fn start(keys: Ed25519KeyPair) -> Result<(), websockets::WebSocketError> {
|
||||||
let mut ws = WebSocket::connect("ws://localhost:8080/").await?;
|
let mut ws = WebSocket::connect("ws://localhost:8080/").await?;
|
||||||
|
|
||||||
ws.send_text("foo".to_string()).await?;
|
let mut interval = time::interval(time::Duration::from_secs(2));
|
||||||
// ws.receive().await?;
|
|
||||||
// ws.close(None).await?;
|
|
||||||
loop {
|
loop {
|
||||||
|
interval.tick().await;
|
||||||
|
println!("Sending: period");
|
||||||
|
ws.send_text("period".to_string()).await?;
|
||||||
let msg = ws.receive().await?;
|
let msg = ws.receive().await?;
|
||||||
|
|
||||||
println!("Received: {:?}", msg);
|
println!("Received: {:?}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user