diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-09-24 07:45:27 +0000 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-09-24 07:45:27 +0000 |
commit | 538d22688c4ae07d8ee9b9d1ec2ebbe80adddf47 (patch) | |
tree | 8f5060a14231f3c0d9c63a27fac79dc242b9a297 /client.c | |
parent | 2acabfaf7308be7517d948743cc6ab9660566327 (diff) |
more extra credit :)
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -143,7 +143,7 @@ int main(int argc, char *argv[]) exit(1); } - if (!waiting) printf("\n", waiting); // note: this is worth the lines for a clean cmd prompt + if (!waiting) printf("\n"); // note: this is worth the lines for a clean cmd prompt waiting = 0; fflush(stdout); printf("New song announced: %s\n", song_name); @@ -197,6 +197,31 @@ int main(int argc, char *argv[]) free(info); continue; } + else if (reply_type == 7) { // we are getting StationShutdown + if (l) printf("received STATIONSHUTDOWN reply.\n"); + if (!waiting) printf("\n"); // note: this is worth the lines for a clean cmd prompt + waiting = 0; + remove_timeout(sockfd); + fflush(stdout); + printf("This station has shut down. Please select different station.\n"); + printf("snowcast_control> "); + fflush(stdout); + continue; + } + else if (reply_type == 8) { // we are getting NewStation + uint16_t station_number = -1; + if (recv(sockfd, &station_number, 2, 0) == -1) { + perror("recv in new station"); + exit(1); + } + station_number = ntohs(station_number); + if (l) printf("received NEWSTATION reply.\n"); + fflush(stdout); + printf("\nThere is now a new station @ index %d.\n", station_number); + printf("snowcast_control> "); + fflush(stdout); + continue; + } printf("\nsocket to server HUNGUP. Exiting.\n"); close(sockfd); @@ -243,7 +268,7 @@ void *command_line_routine(void* args) { // convert input to an int int inputInt = atoi(input); if (input[0] != '0' && inputInt == 0) { - printf("unknown command\n"); + printf("unknown command: %s\n", input); printf("snowcast_control> "); fflush(stdout); continue; @@ -252,7 +277,6 @@ void *command_line_routine(void* args) { // set waiting so no new line on announce waiting = 1; - // send the command to change the station apply_timeout(sockfd); struct SetStation setStation; |