sending WHY2_CHAT_CODE_LIST_SERVER as a code
not sure if it will work (there's no way for me to test it rn...)
This commit is contained in:
parent
1978ed4cd8
commit
e66109c262
@ -720,7 +720,7 @@ void *why2_communicate_thread(void *arg)
|
|||||||
why2_node_t *buffer = head;
|
why2_node_t *buffer = head;
|
||||||
connection_node_t value_buffer;
|
connection_node_t value_buffer;
|
||||||
unsigned long alloc_size = 0;
|
unsigned long alloc_size = 0;
|
||||||
char *append_buffer;
|
size_t last_size = 0;
|
||||||
|
|
||||||
//COUNT REQUIRED MESSAGE ALLOCATION SIZE
|
//COUNT REQUIRED MESSAGE ALLOCATION SIZE
|
||||||
do
|
do
|
||||||
@ -731,29 +731,23 @@ void *why2_communicate_thread(void *arg)
|
|||||||
buffer = buffer -> next; //ITER
|
buffer = buffer -> next; //ITER
|
||||||
} while (buffer != NULL);
|
} while (buffer != NULL);
|
||||||
|
|
||||||
char *message = why2_calloc(strlen(WHY2_CHAT_CODE_LIST_SERVER) + alloc_size + 2, sizeof(char));
|
char *message = why2_calloc(alloc_size + 1, sizeof(char));
|
||||||
buffer = head; //RESET
|
buffer = head; //RESET
|
||||||
|
|
||||||
sprintf(message, WHY2_CHAT_CODE_LIST_SERVER); //SET CODE
|
|
||||||
|
|
||||||
//FILL THE message
|
//FILL THE message
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
value_buffer = *(connection_node_t*) buffer -> value;
|
value_buffer = *(connection_node_t*) buffer -> value;
|
||||||
|
|
||||||
append_buffer = why2_malloc(strlen(value_buffer.username) + why2_count_int_length(value_buffer.id) + 3); //ALLOCATE THE BUFFER
|
sprintf(message + last_size, "%s;%ld;", value_buffer.username, value_buffer.id); //APPEND
|
||||||
sprintf(append_buffer, ";%s;%ld", value_buffer.username, value_buffer.id); //FILL THE BUFFER
|
|
||||||
|
|
||||||
strcat(message, append_buffer); //JOIN THE BUFFER TO OUTPUT message
|
last_size = strlen(message);
|
||||||
|
|
||||||
why2_deallocate(append_buffer); //DEALLOCATION
|
|
||||||
buffer = buffer -> next; //ITER
|
buffer = buffer -> next; //ITER
|
||||||
} while (buffer != NULL);
|
} while (buffer != NULL);
|
||||||
|
|
||||||
strcat(message, ";");
|
|
||||||
|
|
||||||
//SEND
|
//SEND
|
||||||
send_socket_deallocate(message, why2_chat_server_config("server_username"), connection);
|
send_socket_code_deallocate(message, why2_chat_server_config("server_username"), connection, WHY2_CHAT_CODE_LIST_SERVER);
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
why2_deallocate(message);
|
why2_deallocate(message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user