From 779ce6a6885346257b4d18f1efe205984cfff079 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 18 Sep 2023 19:04:14 -0400 Subject: announce message basics done --- client.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index 5edff63..29aad13 100644 --- a/client.c +++ b/client.c @@ -158,13 +158,24 @@ void *reply_thread_routine(void* args) { for (int i = 0; i < recvbytes; i++) { printf("%c ", buf[i]); } - struct Reply reply; - memcpy(&reply, buf, sizeof(struct Reply)); + memcpy(&reply, buf, 2); + + // print out the fields of reply on one line + printf("\nclient: replyType: %d, stringSize: %d\n", reply.replyType, reply.stringSize); + // print the size of reply if (reply.replyType == 3) { printf("client: received an announce message\n"); + char *song_name = malloc(reply.stringSize); + // printf(sizeof(struct Reply)); + memcpy(song_name, buf + 2, reply.stringSize); + + printf("client: song name: %s\n", song_name); + + free(song_name); + continue; } else if (reply.replyType == 4) { printf("client: received an invalid command message\n"); -- cgit v1.2.3-70-g09d2