diff --git a/core/DHT.c b/core/DHT.c index 18f2de38..399d491b 100644 --- a/core/DHT.c +++ b/core/DHT.c @@ -1017,3 +1017,19 @@ int DHT_load(uint8_t * data, uint32_t size) } return 0; } + +//returns 0 if we are not connected to the DHT +//returns 1 if we are +int DHT_isconnected() +{ + uint32_t i; + uint32_t temp_time = unix_time(); + for(i = 0; i < LCLIENT_LIST; i++) + { + if(close_clientlist[i].timestamp + BAD_NODE_TIMEOUT > temp_time) + { + return 1; + } + } + return 0; +} \ No newline at end of file diff --git a/core/DHT.h b/core/DHT.h index d5c2c57d..edc4d344 100644 --- a/core/DHT.h +++ b/core/DHT.h @@ -86,5 +86,8 @@ void DHT_save(uint8_t * data); //return 0 if success int DHT_load(uint8_t * data, uint32_t size); +//returns 0 if we are not connected to the DHT +//returns 1 if we are +int DHT_isconnected(); #endif diff --git a/testing/nTox.c b/testing/nTox.c index acc0be89..d3f6e6a8 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -169,6 +169,7 @@ int main(int argc, char *argv[]) exit(0); } int c; + int on = 0; initMessenger(); m_callback_friendrequest(print_request); m_callback_friendmessage(print_message); @@ -219,6 +220,14 @@ int main(int argc, char *argv[]) break; } } + if(on == 0) + { + if(DHT_isconnected()) + { + new_lines("You are now connected to the DHT."); + on = 1; + } + } doMessenger(); c_sleep(1); do_refresh();