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