Finish ACKs
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user