WIP: hash inequality seems to be happening from something on the wire

This commit is contained in:
Dave Hrycyszyn
2024-06-18 10:17:59 +01:00
parent e9870241cb
commit 416d1ad88b
8 changed files with 92 additions and 21 deletions

View File

@@ -3,17 +3,16 @@ use bft_json_crdt::json_crdt::SignedOp;
use ezsockets::ClientConfig;
use tokio::sync::mpsc;
pub(crate) struct WebSocketClient {
pub struct WebSocketClient {
incoming_sender: mpsc::Sender<SignedOp>,
handle: ezsockets::Client<WebSocketClient>,
}
impl WebSocketClient {
/// Start the websocket client
pub(crate) async fn new(
pub async fn new(
incoming_sender: mpsc::Sender<SignedOp>,
) -> ezsockets::Client<WebSocketClient> {
tracing_subscriber::fmt::init();
let config = ClientConfig::new("ws://localhost:8080/websocket");
let (handle, future) = ezsockets::connect(
|client| WebSocketClient {
@@ -40,7 +39,6 @@ impl ezsockets::ClientExt for WebSocketClient {
/// When we receive a text message, apply the crdt operation contained in it to our
/// local crdt.
async fn on_text(&mut self, text: String) -> Result<(), ezsockets::Error> {
tracing::info!("received text: {text:?}");
let incoming: bft_json_crdt::json_crdt::SignedOp = serde_json::from_str(&text).unwrap();
self.incoming_sender.send(incoming).await?;
Ok(())
@@ -55,7 +53,6 @@ impl ezsockets::ClientExt for WebSocketClient {
/// Call this with the `Call` type to send application data to the websocket client
/// (and from there, to the server).
async fn on_call(&mut self, call: Self::Call) -> Result<(), ezsockets::Error> {
tracing::info!("sending signed op: {call:?}");
self.handle.text(call)?;
Ok(())
}