summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index a6bfbc8a..5dbed346 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -2408,6 +2408,17 @@ uint32_t messenger_run_interval(Messenger *m)
2408/* The main loop that needs to be run at least 20 times per second. */ 2408/* The main loop that needs to be run at least 20 times per second. */
2409void do_messenger(Messenger *m) 2409void do_messenger(Messenger *m)
2410{ 2410{
2411 // Add the TCP relays, but only if this is the first time calling do_messenger
2412 if(m->has_added_relays == 0)
2413 {
2414 m->has_added_relays = 1;
2415
2416 int i;
2417 for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) {
2418 add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id);
2419 }
2420 }
2421
2411 unix_time_update(); 2422 unix_time_update();
2412 2423
2413 if (!m->options.udp_disabled) { 2424 if (!m->options.udp_disabled) {
@@ -2554,7 +2565,6 @@ void do_messenger(Messenger *m)
2554#define MESSENGER_STATE_TYPE_PATH_NODE 11 2565#define MESSENGER_STATE_TYPE_PATH_NODE 11
2555 2566
2556#define SAVED_FRIEND_REQUEST_SIZE 1024 2567#define SAVED_FRIEND_REQUEST_SIZE 1024
2557#define NUM_SAVED_TCP_RELAYS 8
2558#define NUM_SAVED_PATH_NODES 8 2568#define NUM_SAVED_PATH_NODES 8
2559struct SAVED_FRIEND { 2569struct SAVED_FRIEND {
2560 uint8_t status; 2570 uint8_t status;
@@ -2859,25 +2869,6 @@ int messenger_load(Messenger *m, const uint8_t *data, uint32_t length)
2859 return -1; 2869 return -1;
2860} 2870}
2861 2871
2862/* Connect after loading messenger from file */
2863int messenger_connect(Messenger *m)
2864{
2865 int i;
2866
2867 if(m == NULL)
2868 return -1;
2869
2870 DHT *dht = m->dht;
2871 if(DHT_connect_after_load(dht) == -1)
2872 return -1;
2873
2874 for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) {
2875 add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id);
2876 }
2877
2878 return 0;
2879}
2880
2881/* Return the number of friends in the instance m. 2872/* Return the number of friends in the instance m.
2882 * You should use this to determine how much memory to allocate 2873 * You should use this to determine how much memory to allocate
2883 * for copy_friendlist. */ 2874 * for copy_friendlist. */