send new users on chat + cleaning

This commit is contained in:
Arkitu 2025-08-18 14:31:23 +02:00
parent f5fa4647f4
commit 078734e8a1
2 changed files with 8 additions and 11 deletions

View File

@ -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,
}

View File

@ -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> {