mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
ncurses test now tells you when you connect to the DHT.
This commit is contained in:
parent
bec416a050
commit
ffa809b379
16
core/DHT.c
16
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;
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user