Skip to content

Commit

Permalink
reject message if not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
callmeclover authored May 20, 2024
1 parent 72f321b commit eb77182
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ async fn ws_handler(

/// Actual websocket statemachine (one will be spawned per connection)
async fn handle_socket(socket: WebSocket, _who: SocketAddr, state: Arc<AppState>) {
let user_initialized: bool = false;
let (mut sender, mut receiver) = socket.split();
*USER_ID.lock().unwrap() += 1;

Expand Down Expand Up @@ -135,6 +136,7 @@ async fn handle_socket(socket: WebSocket, _who: SocketAddr, state: Arc<AppState>
.expect("couldn't get json from message");
match message {
MessageTypes::MessageSent(mut request) => {
if !user_initialized { continue; }
let mut msg_new: String = String::new();
push_html(
&mut msg_new,
Expand Down

0 comments on commit eb77182

Please sign in to comment.