This commit is contained in:
Lorenzo Bianchi 2023-05-16 23:46:46 +02:00
parent 951d66265a
commit ae96c3b241
4 changed files with 30 additions and 4 deletions

13
TODO.txt Normal file
View File

@ -0,0 +1,13 @@
- magari fare che (alcune delle) print vengano messe su tutti e tre i terminali
(motivo per cui ho messo le funzioni in nonsodovemetterle)
(forse basta tipo duplicare il fd ma sono stanco ci penso domani)
- controllo input dei client
- sistemare include (FARE SOLO ALLA FINE ALTRIMENTI SPRECO DI TEMPO COME LA TUA VITA)
- invece di fare tutti if == -1 si potrebbe fare come semOp e creare una funzione identica
che fa gia il controllo (ha come svantaggio che non puoi specifare dove va in errore con l'errexit)
(anche se forse basta passare la/le stringe ma vedi riga 3)
- killare il server deve uccidere i figli

7
inc/nonsodovemetterle.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef NONSODOVEMETTERLE_H
#define NONSODOVEMETTERLE_H
void printfServer(char *msg);
void printfClient(char *msg);
#endif

View File

@ -157,13 +157,10 @@ int main(int argc, char *argv[]){
if (msgrcv(msgid, &names, sizeof(player_names_t) - sizeof(long), 3, 0) == -1) {
errExit("msgrcv", "ricevuta primo nome");
}
printf("TEST\n");
printf("%d\n", names.id);
printf("%s\n", names.name_player);
// name[names.id] = names.name_player;
printfServer("Player ");
printf("%s connected\n", name[names.id]); //
printf("%s connected\n", name[names.id]);
// aspetto secondo client
semOp(semid, 2, -1);

9
src/nonsodovemetterle.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
void printfServer(char *string){
printf("\033[34m<Server>\033[39m %s", string);
}
void printfClient(char *string){
printf("\033[94m<Client>\033[39m %s", string);
}