mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 19:54:48 +00:00
More cleanup
This commit is contained in:
@@ -42,7 +42,6 @@ pub const ClientState = struct {
|
||||
) void {
|
||||
while (true) {
|
||||
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) {
|
||||
.@"+ok" => {
|
||||
writeOk(self.to_client) catch break;
|
||||
@@ -54,12 +53,7 @@ pub const ClientState = struct {
|
||||
writeInfo(self.to_client, info) catch break;
|
||||
},
|
||||
.msg => |m| {
|
||||
if (writeMsg(self.to_client, m)) |_| {
|
||||
@branchHint(.likely);
|
||||
} else |_| {
|
||||
@branchHint(.unlikely);
|
||||
break;
|
||||
}
|
||||
writeMsg(self.to_client, m) catch break;
|
||||
},
|
||||
else => {
|
||||
std.debug.panic("unimplemented write", .{});
|
||||
|
||||
@@ -86,7 +86,7 @@ fn handleConnection(
|
||||
}
|
||||
const allocator = client_allocator.allocator();
|
||||
defer stream.close(io);
|
||||
var w_buffer: [1024]u8 = undefined;
|
||||
var w_buffer: [4096]u8 = undefined;
|
||||
var writer = stream.writer(io, &w_buffer);
|
||||
const out = &writer.interface;
|
||||
|
||||
@@ -107,7 +107,6 @@ fn handleConnection(
|
||||
defer server.removeClient(allocator, id);
|
||||
|
||||
while (client_state.next(allocator)) |msg| {
|
||||
std.debug.print("message from client: {any}\n", .{msg});
|
||||
switch (msg) {
|
||||
.ping => {
|
||||
// Respond to ping with pong.
|
||||
@@ -118,13 +117,9 @@ fn handleConnection(
|
||||
} else {}
|
||||
},
|
||||
.@"pub" => |@"pub"| {
|
||||
std.debug.print("pub: {any}\n", .{@"pub"});
|
||||
try server.publishMessage(io, @"pub");
|
||||
if (client_state.connect.connect.verbose) {
|
||||
std.debug.print("server IS sending +ok\n", .{});
|
||||
_ = try client_state.send(io, .@"+ok");
|
||||
} else {
|
||||
std.debug.print("server NOT sending +ok\n", .{});
|
||||
}
|
||||
},
|
||||
.sub => |sub| {
|
||||
@@ -137,9 +132,6 @@ fn handleConnection(
|
||||
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| {
|
||||
// This is probably going to be normal on disconnect
|
||||
std.debug.print("Ran into error in client process loop: {}\n", .{err});
|
||||
|
||||
Reference in New Issue
Block a user