diff --git a/src/F4Server.c b/src/F4Server.c index 0a73527..857cc02 100644 --- a/src/F4Server.c +++ b/src/F4Server.c @@ -89,22 +89,22 @@ int main(int argc, char *argv[]){ } while (--turns_left && !(result = checkWin(move.move))); + printf("result: %d\n", result); if (!result) { printf(PSERVER "Game ended in a draw\n"); } else { - printf(PSERVER "Game ended\n"); + printf(PSERVER "%s won\n", name[result]); } game_end_t game_end = {.mtype = GAME_END, .winner = result}; sndGame_end(&game_end); sndGame_end(&game_end); + + printf("%d %d\n", _PIDS[0], _PIDS[1]); kill(_PIDS[0], SIGUSR1); kill(_PIDS[1], SIGUSR1); - - //TODO: end of game - return 0; } diff --git a/src/custom_sig.c b/src/custom_sig.c index 0997f8b..e08190c 100644 --- a/src/custom_sig.c +++ b/src/custom_sig.c @@ -127,11 +127,13 @@ void setServerSignal(int sig) { void sigHandlerClient(int sig) { // Ctrl+C if (sig == SIGINT) { + // per la sicurezza premere una seconda volta chiude il client printf(PCLIENT "Quitting game\n"); game_end_t game = {.mtype = GAME_END, .winner = ID ^ 1}; sndGame_end(&game); printf("server pid: %d\n", SERVER_PID); kill(SERVER_PID, SIGUSR1); + } // Terminazione e chiusura terminale @@ -149,8 +151,10 @@ void sigHandlerClient(int sig) { // Fine partita if (sig == SIGUSR1) { + printf("messaggio?\n"); game_end_t winner; rcvGame_end(&winner); + printf("messaggio!\n"); printBoard(); if (winner.winner == ID) {