Compare commits
2 Commits
b392451486
...
07eb596180
Author | SHA1 | Date | |
---|---|---|---|
07eb596180 | |||
15e36f5919 |
@ -46,6 +46,7 @@ typedef struct _connection_node
|
|||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
char *username;
|
char *username;
|
||||||
unsigned long id;
|
unsigned long id;
|
||||||
|
char *key; //EACH USER WILL USE DIFFERENT KEY FOR COMMUNICATION
|
||||||
} connection_node_t; //SINGLE LINKED LIST
|
} connection_node_t; //SINGLE LINKED LIST
|
||||||
|
|
||||||
why2_list_t connection_list = WHY2_LIST_EMPTY;
|
why2_list_t connection_list = WHY2_LIST_EMPTY;
|
||||||
@ -658,7 +659,8 @@ void *why2_communicate_thread(void *arg)
|
|||||||
connection,
|
connection,
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
why2_strdup(username),
|
why2_strdup(username),
|
||||||
get_latest_id()
|
get_latest_id(),
|
||||||
|
why2_generate_key(why2_get_key_length())
|
||||||
};
|
};
|
||||||
|
|
||||||
why2_list_push(&connection_list, &node, sizeof(node)); //ADD TO LIST
|
why2_list_push(&connection_list, &node, sizeof(node)); //ADD TO LIST
|
||||||
@ -856,6 +858,7 @@ void *why2_communicate_thread(void *arg)
|
|||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
close(connection);
|
close(connection);
|
||||||
why2_deallocate(node.username);
|
why2_deallocate(node.username);
|
||||||
|
why2_deallocate(node.key);
|
||||||
|
|
||||||
why2_list_remove(&connection_list, find_connection(connection));
|
why2_list_remove(&connection_list, find_connection(connection));
|
||||||
|
|
||||||
@ -959,6 +962,8 @@ void *why2_listen_server(void *socket)
|
|||||||
|
|
||||||
if (server_uname == NULL) //GET SERVER USERNAME
|
if (server_uname == NULL) //GET SERVER USERNAME
|
||||||
{
|
{
|
||||||
|
if (code == NULL || strcmp(code, WHY2_CHAT_CODE_ACCEPT_MESSAGES) != 0) goto deallocation;
|
||||||
|
|
||||||
server_uname = why2_strdup(username); //GET USERNAME
|
server_uname = why2_strdup(username); //GET USERNAME
|
||||||
|
|
||||||
//GET INFO
|
//GET INFO
|
||||||
@ -1094,13 +1099,14 @@ void *why2_listen_server(void *socket)
|
|||||||
printf("\n\n%s%s: %s\n\n", WHY2_CLEAR_AND_GO_UP, username, message);
|
printf("\n\n%s%s: %s\n\n", WHY2_CLEAR_AND_GO_UP, username, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!exiting && !continuing)
|
if (!exiting && !continuing)
|
||||||
{
|
{
|
||||||
printf(">>> ");
|
printf(">>> ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deallocation:
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
why2_deallocate(read);
|
why2_deallocate(read);
|
||||||
why2_deallocate(username);
|
why2_deallocate(username);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user