server03 passed
This commit is contained in:
@@ -45,7 +45,7 @@ void *handle_connection(void *args) {
|
|||||||
status_t status = CONNECTED;
|
status_t status = CONNECTED;
|
||||||
char *message = malloc(sizeof(char)*1024);
|
char *message = malloc(sizeof(char)*1024);
|
||||||
char_array_t *data = char_array_create(1024);
|
char_array_t *data = char_array_create(1024);
|
||||||
send(handleArgs->client, WELCOME, sizeof(WELCOME), 0);
|
send(handleArgs->client, WELCOME, sizeof(WELCOME)-1, 0);
|
||||||
char *username = malloc(sizeof(char)*1024);
|
char *username = malloc(sizeof(char)*1024);
|
||||||
while ((bytesReceived = recv(handleArgs->client, buffer, sizeof(buffer), 0)) > 0) {
|
while ((bytesReceived = recv(handleArgs->client, buffer, sizeof(buffer), 0)) > 0) {
|
||||||
printf("{%d} Client sent: |%d| \n", handleArgs->connection, bytesReceived);
|
printf("{%d} Client sent: |%d| \n", handleArgs->connection, bytesReceived);
|
||||||
@@ -102,8 +102,10 @@ void *handle_connection(void *args) {
|
|||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
}
|
}
|
||||||
|
if (status == IDENTIFIED) {
|
||||||
sprintf(message, "* %s has left the room\n", username);
|
sprintf(message, "* %s has left the room\n", username);
|
||||||
broadcast(handleArgs->connections, &handleArgs->client, message);
|
broadcast(handleArgs->connections, &handleArgs->client, message);
|
||||||
|
}
|
||||||
connections_remove(handleArgs->connections, handleArgs->client);
|
connections_remove(handleArgs->connections, handleArgs->client);
|
||||||
printf("{%d} Client disconnected\n", handleArgs->connection);
|
printf("{%d} Client disconnected\n", handleArgs->connection);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user