tox_isconnected() now works on TCP only.

This commit is contained in:
irungentoo 2014-08-14 15:41:10 -04:00
parent 1298932deb
commit 5376d40f54
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
3 changed files with 23 additions and 1 deletions

View File

@ -1274,3 +1274,19 @@ void kill_onion_client(Onion_Client *onion_c)
memset(onion_c, 0, sizeof(Onion_Client));
free(onion_c);
}
/* return 0 if we are not connected to the network.
* return 1 if we are.
*/
int onion_isconnected(const Onion_Client *onion_c)
{
unsigned int i;
for (i = 0; i < MAX_ONION_CLIENTS; ++i) {
if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT))
return 1;
}
return 0;
}

View File

@ -236,4 +236,10 @@ Onion_Client *new_onion_client(Net_Crypto *c);
void kill_onion_client(Onion_Client *onion_c);
/* return 0 if we are not connected to the network.
* return 1 if we are.
*/
int onion_isconnected(const Onion_Client *onion_c);
#endif

View File

@ -796,7 +796,7 @@ int tox_bootstrap_from_address(Tox *tox, const char *address,
int tox_isconnected(const Tox *tox)
{
const Messenger *m = tox;
return DHT_isconnected(m->dht);
return DHT_isconnected(m->dht) || onion_isconnected(m->onion_c);
}
/* Return the time in milliseconds before tox_do() should be called again