Skip to content

Commit

Permalink
Reworks some strings and adds a latest chack on SSL_read call
Browse files Browse the repository at this point in the history
  • Loading branch information
HorlogeSkynet committed May 30, 2017
1 parent 29968f3 commit c4efa81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/commands/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void* server_communication(void *param)

if(result <= 0 || !strcmp(buffer, DISCONNECT))
{
printf("\n\n[sthread] Server is demanding this client disconnection. Stopping now.");
printf("\n\033[35m[SERVER] is demanding this client disconnection. Stopping now.\033[0m");
pthread_cancel(*(threads->cthread));
pthread_exit(NULL);
}
Expand All @@ -26,7 +26,7 @@ void* server_communication(void *param)
/* We received from server a non-null string, let's print it */
if(strcmp(buffer, ""))
{
printf("\n\n[sthread] %s\n\n", buffer);
printf("\n\033[35m[SERVER] %s\033[0m\n\n", buffer);
command_cursor();
}
}
Expand Down
10 changes: 8 additions & 2 deletions client/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,15 @@ bool start_client(void)
printf(".\033[0m\n");

strncpy(buffer, "", BUFFER);
SSL_read(ssl, buffer, BUFFER);

if(SSL_read(ssl, buffer, BUFFER) <= 0)
{
printf("\n\033[31m[WIFSS] Couldn\'t get your ID from server, exiting now.\033[0m\n\n");
exit(EXIT_FAILURE);
}

uint16_t idTemp = getSecondArgsGroupAsInteger(buffer);
printf("\n\033[32m[WIFSS] Your id on the server is %d.\033[0m\n\n", idTemp);
printf("\n\033[32m[WIFSS] Your ID on the server is %d.\033[0m\n\n", idTemp);

/* We save the ID of the client for the future */
g_core_variables.client_id = idTemp;
Expand Down

0 comments on commit c4efa81

Please sign in to comment.