WIP: hash inequality seems to be happening from something on the wire
This commit is contained in:
@@ -8,6 +8,10 @@ edition = "2021"
|
||||
[dependencies]
|
||||
async-trait = "0.1.52"
|
||||
ezsockets = { version = "*", features = ["tungstenite"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
sha256 = "1.5.0"
|
||||
side-node = { path = "../side-node" }
|
||||
tokio = { version = "1.17.0", features = ["full"] }
|
||||
tracing = "0.1.32"
|
||||
tracing-subscriber = "0.3.9"
|
||||
|
||||
@@ -85,12 +85,13 @@ impl ezsockets::ServerExt for ChatServer {
|
||||
.unzip();
|
||||
|
||||
tracing::info!(
|
||||
"sending {text} to [{sessions}] at `{room}`",
|
||||
"sending {hash} to [{sessions}] at `{room}`",
|
||||
sessions = ids
|
||||
.iter()
|
||||
.map(|id| id.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
.join(","),
|
||||
hash = shappy(text.clone())
|
||||
);
|
||||
for session in sessions {
|
||||
session.text(text.clone()).unwrap();
|
||||
@@ -144,7 +145,7 @@ impl ezsockets::SessionExt for SessionActor {
|
||||
}
|
||||
|
||||
async fn on_text(&mut self, text: String) -> Result<(), Error> {
|
||||
tracing::info!("received: {text}");
|
||||
tracing::info!("received: {}", shappy(text.clone()));
|
||||
if text.starts_with('/') {
|
||||
let mut args = text.split_whitespace();
|
||||
let command = args.next().unwrap();
|
||||
@@ -183,6 +184,11 @@ impl ezsockets::SessionExt for SessionActor {
|
||||
}
|
||||
}
|
||||
|
||||
fn shappy(text: String) -> String {
|
||||
let b = text.into_bytes();
|
||||
sha256::digest(b).to_string()
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
Reference in New Issue
Block a user