sending server exit_cmd with the initial welcome message
This commit is contained in:
parent
c98184f1f5
commit
1fc78a2a30
@ -108,16 +108,20 @@ int main(void)
|
|||||||
|
|
||||||
//TODO: Remove accents
|
//TODO: Remove accents
|
||||||
|
|
||||||
why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT
|
|
||||||
|
|
||||||
if (strcmp(line, WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\n") == 0) //USER REQUESTED PROGRAM EXIT
|
if (strcmp(line, WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\n") == 0) //USER REQUESTED PROGRAM EXIT
|
||||||
{
|
{
|
||||||
printf("Exiting...\n");
|
printf("Exiting...\n");
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
char *exit_cmd = why2_chat_client_get_server_exit_cmd();
|
||||||
|
|
||||||
|
why2_send_socket(exit_cmd, NULL, listen_socket);
|
||||||
|
why2_deallocate(exit_cmd);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT
|
||||||
free(return_line);
|
free(return_line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
if (!ssqc)
|
if (!ssqc)
|
||||||
|
@ -382,6 +382,8 @@ void send_socket(char *text, char *username, int socket, why2_bool welcome)
|
|||||||
json_object_object_add(json, "min_uname", json_object_new_string(min_uname));
|
json_object_object_add(json, "min_uname", json_object_new_string(min_uname));
|
||||||
json_object_object_add(json, "max_tries", json_object_new_string(max_tries));
|
json_object_object_add(json, "max_tries", json_object_new_string(max_tries));
|
||||||
|
|
||||||
|
json_object_object_add(json, "exit_cmd", json_object_new_string(WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT));
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
why2_toml_read_free(max_uname);
|
why2_toml_read_free(max_uname);
|
||||||
why2_toml_read_free(min_uname);
|
why2_toml_read_free(min_uname);
|
||||||
@ -802,6 +804,7 @@ void *why2_listen_server(void *socket)
|
|||||||
max_uname = get_int_from_json_string(read, "max_uname");
|
max_uname = get_int_from_json_string(read, "max_uname");
|
||||||
min_uname = get_int_from_json_string(read, "min_uname");
|
min_uname = get_int_from_json_string(read, "min_uname");
|
||||||
max_tries = get_int_from_json_string(read, "max_tries");
|
max_tries = get_int_from_json_string(read, "max_tries");
|
||||||
|
why2_chat_client_set_server_exit_cmd(get_string_from_json_string(read, "exit_cmd"));
|
||||||
|
|
||||||
continuing = 1;
|
continuing = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user