some cleanup and freeing

This commit is contained in:
2025-12-31 02:13:15 +00:00
parent e60a566a7c
commit 0f138e5984
3 changed files with 23 additions and 10 deletions

View File

@@ -111,22 +111,35 @@ fn handleConnection(
switch (msg) {
.ping => {
// Respond to ping with pong.
for (0..5) |_| {
if (try client_state.send(io, .pong)) {
break;
}
} else {}
try client_state.send(io, .pong);
},
.@"pub" => |@"pub"| {
try server.publishMessage(io, @"pub");
.@"pub" => |pb| {
defer {
allocator.free(pb.payload);
allocator.free(pb.subject);
if (pb.reply_to) |r| {
allocator.free(r);
}
}
try server.publishMessage(io, pb);
if (client_state.connect.connect.verbose) {
_ = try client_state.send(io, .@"+ok");
try client_state.send(io, .@"+ok");
}
},
.sub => |sub| {
defer {
allocator.free(sub.subject);
allocator.free(sub.sid);
if (sub.queue_group) |q| {
allocator.free(q);
}
}
try server.subscribe(allocator, id, sub);
},
.unsub => |unsub| {
defer {
allocator.free(unsub.sid);
}
try server.unsubscribe(id, unsub);
},
else => |e| {