diff options
| author | Robby Zambito <contact@robbyzambito.me> | 2025-12-31 01:05:05 +0000 |
|---|---|---|
| committer | Robby Zambito <contact@robbyzambito.me> | 2026-01-01 05:22:02 +0000 |
| commit | e60a566a7c61cacc09213a23a708ab2f7d78a3ac (patch) | |
| tree | b9680f8c889de00f09f9239074194945b08f4f3d /src/server/main.zig | |
| parent | 1cbd030037f4f936044957152f7c3e2e6a234576 (diff) | |
Cleanup client
Break up creating and starting the client process.
I think this should simplify storing the std.Io.Queue on the stack.
Before I was storing it on the heap because it was hard to make it point to the same location if I was initializing the client on the stack.
Diffstat (limited to 'src/server/main.zig')
| -rw-r--r-- | src/server/main.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/server/main.zig b/src/server/main.zig index 7e3f503..0045c1c 100644 --- a/src/server/main.zig +++ b/src/server/main.zig @@ -100,7 +100,8 @@ fn handleConnection( var connect_arena: std.heap.ArenaAllocator = .init(allocator); defer connect_arena.deinit(); const connect = (Message.next(connect_arena.allocator(), in) catch return).connect; - var client_state: ClientState = try .init(io, allocator, id, connect, in, out); + var client_state: ClientState = try .init(connect, in, out); + try client_state.start(io); defer client_state.deinit(io, allocator); try server.addClient(allocator, id, &client_state); @@ -123,10 +124,10 @@ fn handleConnection( } }, .sub => |sub| { - try server.subscribe(allocator, client_state.id, sub); + try server.subscribe(allocator, id, sub); }, .unsub => |unsub| { - try server.unsubscribe(client_state.id, unsub); + try server.unsubscribe(id, unsub); }, else => |e| { std.debug.panic("Unimplemented message: {any}\n", .{e}); |
