aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/client.c b/client.c
index 4ca1165..6773c86 100644
--- a/client.c
+++ b/client.c
@@ -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;