This commit is contained in:
2025-12-29 00:35:06 +00:00
parent 18f4475aaf
commit 335c4aa092
3 changed files with 43 additions and 20 deletions

View File

@@ -77,7 +77,7 @@ pub const ClientState = struct {
}
/// Return true if the value was put in the clients buffer to process, else false.
pub fn send(self: *ClientState, io: std.Io, msg: Message) (std.Io.Cancelable||std.Io.QueueClosedError)!bool {
pub fn send(self: *ClientState, io: std.Io, msg: Message) (std.Io.Cancelable || std.Io.QueueClosedError)!bool {
try self.recv_queue.putOne(io, msg);
return true;
}
@@ -110,6 +110,16 @@ pub fn writeInfo(out: *std.Io.Writer, info: Message.ServerInfo) !void {
fn writeMsg(out: *std.Io.Writer, msg: Message.Msg) !void {
std.debug.print("PRINTING MESSAGE\n\n\n\n", .{});
std.debug.print(
"MSG {s} {s} {s} {d}\r\n{s}\r\n-\n\n\n",
.{
msg.subject,
msg.sid,
msg.reply_to orelse "",
msg.payload.len,
msg.payload,
},
);
try out.print(
"MSG {s} {s} {s} {d}\r\n{s}\r\n",
.{
@@ -135,6 +145,7 @@ test {
var from_client_queue: std.Io.Queue(Message) = .init(&from_client_buf);
{
// Simulate stream
while (Message.next(gpa, &from_client)) |msg| {
switch (msg) {
.eos => {
@@ -145,7 +156,10 @@ test {
try from_client_queue.putOne(io, msg);
},
}
} else |_| {}
} else |err| switch (err) {
error.EndOfStream => try from_client_queue.close(io),
else => return err,
}
while (from_client_queue.getOne(io)) |msg| {
switch (msg) {