Fixed issue where callbacks were not set for accepted connection.

This commit is contained in:
irungentoo 2014-05-11 19:35:23 -04:00
parent 1580a5c696
commit 87cec79206
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 9 additions and 2 deletions

View File

@ -1738,6 +1738,9 @@ static void LANdiscovery(Messenger *m)
} }
} }
static int handle_status(void *object, int i, uint8_t status);
static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len);
static int handle_new_connections(void *object, New_Connection *n_c) static int handle_new_connections(void *object, New_Connection *n_c)
{ {
Messenger *m = object; Messenger *m = object;
@ -1747,8 +1750,12 @@ static int handle_new_connections(void *object, New_Connection *n_c)
if (m->friendlist[friend_id].crypt_connection_id != -1) if (m->friendlist[friend_id].crypt_connection_id != -1)
return -1; return -1;
m->friendlist[friend_id].crypt_connection_id = accept_crypto_connection(m->net_crypto, n_c); int id = accept_crypto_connection(m->net_crypto, n_c);
connection_status_handler(m->net_crypto, id, &handle_status, m, friend_id);
connection_data_handler(m->net_crypto, id, &handle_packet, m, friend_id);
m->friendlist[friend_id].crypt_connection_id = id;
set_friend_status(m, friend_id, FRIEND_CONFIRMED); set_friend_status(m, friend_id, FRIEND_CONFIRMED);
return 0;
} }
return -1; return -1;

View File

@ -1527,7 +1527,7 @@ static void send_crypto_packets(Net_Crypto *c)
send_temp_packet(c, i); send_temp_packet(c, i);
} }
if (conn->status >= CRYPTO_CONN_NOT_CONFIRMED if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED)
&& (CRYPTO_SEND_PACKET_INTERVAL + conn->last_request_packet_sent) < temp_time) { && (CRYPTO_SEND_PACKET_INTERVAL + conn->last_request_packet_sent) < temp_time) {
if (send_request_packet(c, i) == 0) { if (send_request_packet(c, i) == 0) {
conn->last_request_packet_sent = temp_time; conn->last_request_packet_sent = temp_time;