summaryrefslogtreecommitdiff
path: root/toxcore/friend_connection.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-04-27 16:13:04 -0400
committerirungentoo <irungentoo@gmail.com>2015-04-27 16:13:04 -0400
commit69e3e5f3a4510e4883edecc78b5556d38cb61318 (patch)
treed3bd18907f54b1d115c628e79860221486e5cf2f /toxcore/friend_connection.c
parent6a1efc32e635a86b0d848d058ba152403c49bec2 (diff)
Move LAN discovery from Messenger to friend_connection.
Diffstat (limited to 'toxcore/friend_connection.c')
-rw-r--r--toxcore/friend_connection.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c
index 5182ce28..c13ca949 100644
--- a/toxcore/friend_connection.c
+++ b/toxcore/friend_connection.c
@@ -758,10 +758,20 @@ Friend_Connections *new_friend_connections(Onion_Client *onion_c)
758 temp->onion_c = onion_c; 758 temp->onion_c = onion_c;
759 759
760 new_connection_handler(temp->net_crypto, &handle_new_connections, temp); 760 new_connection_handler(temp->net_crypto, &handle_new_connections, temp);
761 LANdiscovery_init(temp->dht);
761 762
762 return temp; 763 return temp;
763} 764}
764 765
766/* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */
767static void LANdiscovery(Friend_Connections *fr_c)
768{
769 if (fr_c->last_LANdiscovery + LAN_DISCOVERY_INTERVAL < unix_time()) {
770 send_LANdiscovery(htons(TOX_PORT_DEFAULT), fr_c->dht);
771 fr_c->last_LANdiscovery = unix_time();
772 }
773}
774
765/* main friend_connections loop. */ 775/* main friend_connections loop. */
766void do_friend_connections(Friend_Connections *fr_c) 776void do_friend_connections(Friend_Connections *fr_c)
767{ 777{
@@ -809,6 +819,8 @@ void do_friend_connections(Friend_Connections *fr_c)
809 } 819 }
810 } 820 }
811 } 821 }
822
823 LANdiscovery(fr_c);
812} 824}
813 825
814/* Free everything related with friend_connections. */ 826/* Free everything related with friend_connections. */
@@ -823,5 +835,6 @@ void kill_friend_connections(Friend_Connections *fr_c)
823 kill_friend_connection(fr_c, i); 835 kill_friend_connection(fr_c, i);
824 } 836 }
825 837
838 LANdiscovery_kill(fr_c->dht);
826 free(fr_c); 839 free(fr_c);
827} 840}