From 078734e8a1479438312253bee524497d8bd2cddc Mon Sep 17 00:00:00 2001 From: Arkitu <85173315+Arkitu@users.noreply.github.com> Date: Mon, 18 Aug 2025 14:31:23 +0200 Subject: [PATCH] send new users on chat + cleaning --- src/apps/chat.rs | 8 +++----- src/socket/ws.rs | 11 +++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/apps/chat.rs b/src/apps/chat.rs index d5f6590..c60008b 100644 --- a/src/apps/chat.rs +++ b/src/apps/chat.rs @@ -1,10 +1,10 @@ -use core::{str::from_utf8_unchecked, sync::atomic::Ordering}; +use core::sync::atomic::Ordering; -use embassy_sync::{blocking_mutex::raw::ThreadModeRawMutex, mutex::Mutex, signal::Signal}; +use embassy_sync::{blocking_mutex::raw::ThreadModeRawMutex, mutex::Mutex}; use embassy_time::{Duration, Timer}; use heapless::String; use log::{info, warn}; -use pico_website::{unimplemented, unwrap, unwrap_opt}; +use pico_website::unimplemented; use portable_atomic::AtomicUsize; use serde::Serialize; @@ -162,7 +162,6 @@ pub static USERNAMES_VERSION: AtomicUsize = AtomicUsize::new(0); pub struct ChatApp { id: u8, - json_buf: [u8; 48 + USERNAME_MAX_LEN + MSG_MAX_SIZE], /// Id of the next message to send to client (so that 0 means no message has been sent) next_msg: usize, usernames_version: usize, @@ -171,7 +170,6 @@ impl ChatApp { pub fn new(id: u8) -> Self { Self { id, - json_buf: [0; _], next_msg: 0, usernames_version: 0, } diff --git a/src/socket/ws.rs b/src/socket/ws.rs index 207347e..ed3467e 100644 --- a/src/socket/ws.rs +++ b/src/socket/ws.rs @@ -1,11 +1,10 @@ -use core::str::{from_utf8, from_utf8_unchecked}; +use core::str::from_utf8; use embassy_net::tcp::{TcpReader, TcpSocket, TcpWriter}; -use embassy_time::{Instant, Timer}; -use embedded_io_async::{ErrorType, ReadReady, Write}; -use heapless::Vec; -use log::{info, warn}; -use pico_website::{assert, expect_opt, unwrap, unwrap_opt}; +use embassy_time::Instant; +use embedded_io_async::ReadReady; +use log::warn; +use pico_website::{assert, unwrap, unwrap_opt}; #[derive(Clone, Copy, Debug)] pub enum WsMsg<'a> {