treesummaryrefslogcommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick2026-05-08 02:20:42 +0200
committerPatrick2026-05-08 02:20:42 +0200
commitfedf10f71a157003006d41afc7821517f06c7abd (patch)
tree76ecdeb83632b761ba2cc1075aeddb023ba8bbc1 /src
parent6eabc8b45aaad9ca4d5d49311a4bac2f4aefeb11 (diff)
downloadzhttpws-fedf10f71a157003006d41afc7821517f06c7abd.tar.gz
zhttpws-fedf10f71a157003006d41afc7821517f06c7abd.zip
print client count
Diffstat (limited to 'src')
-rw-r--r--src/main.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 3616370..3204b4d 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -17,10 +17,14 @@ fn broadcast(sm: WebSocket.SmallMessage) void {
fn handle_websocket(alloc: std.mem.Allocator, websocket: *WebSocket) void {
if (!m.tryLock()) return;
clients.append(alloc, websocket) catch {};
+ std.debug.print("{} clients\n", .{clients.items.len});
m.unlock();
const i = clients.items.len;
- defer _ = clients.swapRemove(i);
+ defer {
+ _ = clients.swapRemove(i);
+ std.debug.print("{} clients\n", .{clients.items.len});
+ }
websocket.writeMessage("welcome", .text) catch return;