removed gotos from why2_communicate_thread msg loop
This commit is contained in:
parent
1e6c297b57
commit
857a3afe95
@ -509,10 +509,11 @@ void *why2_communicate_thread(void *arg)
|
|||||||
|
|
||||||
if (decoded_buffer == NULL) //idk sometimes this happen, idk why
|
if (decoded_buffer == NULL) //idk sometimes this happen, idk why
|
||||||
{
|
{
|
||||||
force_exiting = 1;
|
force_exiting = 1; //force exit <3
|
||||||
goto deallocation;
|
} else
|
||||||
}
|
{
|
||||||
|
if (strlen(decoded_buffer) != 0)
|
||||||
|
{
|
||||||
if (decoded_buffer[0] == '!') //COMMANDS
|
if (decoded_buffer[0] == '!') //COMMANDS
|
||||||
{
|
{
|
||||||
if (strcmp(decoded_buffer, "!exit") == 0) //USER REQUESTED EXIT
|
if (strcmp(decoded_buffer, "!exit") == 0) //USER REQUESTED EXIT
|
||||||
@ -520,12 +521,12 @@ void *why2_communicate_thread(void *arg)
|
|||||||
exiting = 1;
|
exiting = 1;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
why2_send_socket(WHY2_CHAT_CODE_INVALID_COMMAND, WHY2_CHAT_SERVER_USERNAME, connection);
|
why2_send_socket(WHY2_CHAT_CODE_INVALID_COMMAND, WHY2_CHAT_SERVER_USERNAME, connection); //INFORM USER THAT HE'S DUMB
|
||||||
}
|
|
||||||
|
|
||||||
goto deallocation; //IGNORE MESSAGES BEGINNING WITH '!'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//IGNORE MESSAGES BEGINNING WITH '!'
|
||||||
|
} else
|
||||||
|
{
|
||||||
//REBUILD MESSAGE WITH USERNAME
|
//REBUILD MESSAGE WITH USERNAME
|
||||||
json_object_object_add(json, "message", json_object_new_string(decoded_buffer));
|
json_object_object_add(json, "message", json_object_new_string(decoded_buffer));
|
||||||
json_object_object_add(json, "username", json_object_new_string(get_username(connection)));
|
json_object_object_add(json, "username", json_object_new_string(get_username(connection)));
|
||||||
@ -537,9 +538,13 @@ void *why2_communicate_thread(void *arg)
|
|||||||
add_brackets(&raw_output);
|
add_brackets(&raw_output);
|
||||||
|
|
||||||
send_to_all(raw_output); //e
|
send_to_all(raw_output); //e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deallocation:
|
deallocation:
|
||||||
|
|
||||||
|
//DEALLOCATION
|
||||||
why2_deallocate(raw);
|
why2_deallocate(raw);
|
||||||
why2_deallocate(raw_ptr);
|
why2_deallocate(raw_ptr);
|
||||||
why2_deallocate(raw_output);
|
why2_deallocate(raw_output);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user