aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-18 19:04:14 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-18 19:04:14 -0400
commit779ce6a6885346257b4d18f1efe205984cfff079 (patch)
tree53506cea5688a2f31ceddd3e837205f90c2d9a02 /client.c
parent186915db036f06a604883b644e40eaf377aedadf (diff)
announce message basics done
Diffstat (limited to 'client.c')
-rw-r--r--client.c15
1 files changed, 13 insertions, 2 deletions
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");