mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 11:44:48 +00:00
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.
This commit is contained in:
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user