Finish ACKs

This commit is contained in:
2026-01-26 23:21:34 +01:00
parent 6ecbdfa9fa
commit 20df30ace8
2 changed files with 63 additions and 19 deletions
+9 -5
View File
@@ -278,9 +278,13 @@ int main(int argc, char *argv[]) {
}
switch (incoming.mtype) {
case Message:
case Message: {
printf("%s: %s\n", incoming.sender, incoming.message);
msgbuf_t ack = {.mtype = Signal, .stype = ACK_DELIVERED, .command = ""};
strncpy(ack.command, incoming.command, COMMAND_LENGTH);
send(server_queue_id, &ack);
break;
}
case List: {
// Check the command field for the list type
if (strncmp(incoming.command, "active", COMMAND_LENGTH) == 0) {
@@ -316,14 +320,14 @@ int main(int argc, char *argv[]) {
case Signal:
// Tell the user if the previous message was accepted and/or delivered
if (incoming.stype == ACK_ACCEPTED) {
printf("Message sent successfully.\n");
printf("[Sent]\n");
} else if (incoming.stype == ACK_DELIVERED) {
printf("Message delivered to %s.\n", incoming.sender);
printf("[Delivered: %s]\n", incoming.sender);
} else if (incoming.stype == ERR_NOT_FOUND) {
printf("Your message could not be delivered: User not found.\n");
printf("[Error: User not found]\n");
} else {
// Display whatever if I forgot to handle something
printf("Unhandled signal - code %d.\n", incoming.stype);
printf("[Error: Code %d]\n", incoming.stype);
}
break;
case JoinGroup: