Obsolete
/
libipc-old
Archived
3
0
Fork 0

Do not quit after timeout.

master
Karchnu 2022-12-26 08:21:29 +01:00
parent e7c1c8b96d
commit 1a161d1b14
1 changed files with 14 additions and 10 deletions

View File

@ -38,6 +38,8 @@ test {
_ = @import("./util.zig");
}
var should_quit: bool = false;
fn create_service() !void {
const config = .{.safety = true};
var gpa = std.heap.GeneralPurposeAllocator(config){};
@ -52,7 +54,8 @@ fn create_service() !void {
// SERVER SIDE: creating a service.
_ = try ctx.server_init(path);
var count_down: i16 = 5;
// TODO: signal handler, to quit when asked
var some_event: Event = undefined;
ctx.timer = 2000; // 1 second
while(true) {
@ -62,19 +65,16 @@ fn create_service() !void {
print("New connection: {}!\n", .{some_event});
},
.TIMER => {
print("Timer! ({})\n", .{count_down});
count_down -= 1;
if(count_down < 0) {
print("STOP WAITING!\n", .{});
break;
}
print("Timer!\n", .{});
},
.EXTERNAL => {
print("Message received from a non IPC socket.\n", .{});
print("NOT IMPLEMENTED, YET. It's a suicide, then.\n", .{});
break;
},
.SWITCH => {
print("Message to send to a corresponding fd.\n", .{});
print("NOT IMPLEMENTED, YET. It's a suicide, then.\n", .{});
break;
},
.DISCONNECTION => {
@ -89,21 +89,25 @@ fn create_service() !void {
},
.LOOKUP => {
print("Client asking for a service through ipcd.\n", .{});
print("NOT IMPLEMENTED, YET. It's a suicide, then.\n", .{});
break;
},
.TX => {
print("Message sent.\n", .{});
break;
},
.NOT_SET => {
print("Event type not set.\n", .{});
print("Event type not set. Something is wrong, let's suicide.\n", .{});
break;
},
.ERROR => {
print("A problem occured, event: {}\n", .{some_event});
print("A problem occured, event: {}, let's suicide\n", .{some_event});
break;
},
}
if (should_quit) {
break;
}
}