More cleanup

This commit is contained in:
2025-12-29 04:56:48 +00:00
parent b9d0672971
commit fe4c1d410b
2 changed files with 2 additions and 16 deletions

View File

@@ -42,7 +42,6 @@ pub const ClientState = struct {
) void { ) void {
while (true) { while (true) {
const message = self.recv_queue.getOne(io) catch break; const message = self.recv_queue.getOne(io) catch break;
std.debug.print("got message in write loop to send to client: {any}\n", .{message});
switch (message) { switch (message) {
.@"+ok" => { .@"+ok" => {
writeOk(self.to_client) catch break; writeOk(self.to_client) catch break;
@@ -54,12 +53,7 @@ pub const ClientState = struct {
writeInfo(self.to_client, info) catch break; writeInfo(self.to_client, info) catch break;
}, },
.msg => |m| { .msg => |m| {
if (writeMsg(self.to_client, m)) |_| { writeMsg(self.to_client, m) catch break;
@branchHint(.likely);
} else |_| {
@branchHint(.unlikely);
break;
}
}, },
else => { else => {
std.debug.panic("unimplemented write", .{}); std.debug.panic("unimplemented write", .{});

View File

@@ -86,7 +86,7 @@ fn handleConnection(
} }
const allocator = client_allocator.allocator(); const allocator = client_allocator.allocator();
defer stream.close(io); defer stream.close(io);
var w_buffer: [1024]u8 = undefined; var w_buffer: [4096]u8 = undefined;
var writer = stream.writer(io, &w_buffer); var writer = stream.writer(io, &w_buffer);
const out = &writer.interface; const out = &writer.interface;
@@ -107,7 +107,6 @@ fn handleConnection(
defer server.removeClient(allocator, id); defer server.removeClient(allocator, id);
while (client_state.next(allocator)) |msg| { while (client_state.next(allocator)) |msg| {
std.debug.print("message from client: {any}\n", .{msg});
switch (msg) { switch (msg) {
.ping => { .ping => {
// Respond to ping with pong. // Respond to ping with pong.
@@ -118,13 +117,9 @@ fn handleConnection(
} else {} } else {}
}, },
.@"pub" => |@"pub"| { .@"pub" => |@"pub"| {
std.debug.print("pub: {any}\n", .{@"pub"});
try server.publishMessage(io, @"pub"); try server.publishMessage(io, @"pub");
if (client_state.connect.connect.verbose) { if (client_state.connect.connect.verbose) {
std.debug.print("server IS sending +ok\n", .{});
_ = try client_state.send(io, .@"+ok"); _ = try client_state.send(io, .@"+ok");
} else {
std.debug.print("server NOT sending +ok\n", .{});
} }
}, },
.sub => |sub| { .sub => |sub| {
@@ -137,9 +132,6 @@ fn handleConnection(
std.debug.panic("Unimplemented message: {any}\n", .{e}); std.debug.panic("Unimplemented message: {any}\n", .{e});
}, },
} }
std.debug.print("processed message from client\n", .{});
std.debug.print("awaiting next message from client\n", .{});
} else |err| { } else |err| {
// This is probably going to be normal on disconnect // This is probably going to be normal on disconnect
std.debug.print("Ran into error in client process loop: {}\n", .{err}); std.debug.print("Ran into error in client process loop: {}\n", .{err});