Added multi-threading so user input doens't hold up checking the network

This commit is contained in:
Astonex 2013-07-30 01:27:48 +01:00
parent 7e973c8cac
commit 59ccce35a6

View File

@ -24,6 +24,8 @@
#include "nTox_win32.h"
#include "misc_tools.h"
#include <process.h>
uint8_t pending_requests[256][CLIENT_ID_SIZE];
uint8_t num_requests;
@ -200,6 +202,15 @@ void line_eval(char* line)
}
}
void get_input()
{
while(1) {
fgets(line, STRING_LENGTH, stdin);
line_eval(line);
strcpy(line, "");
}
}
int main(int argc, char *argv[])
{
if (argc < 4) {
@ -264,6 +275,8 @@ int main(int argc, char *argv[])
int c;
int on = 0;
_beginthread(get_input, 0, NULL);
while(1) {
if (on == 0 && DHT_isconnected()) {
printf("\n[i] connected to DHT\n\n");
@ -271,12 +284,6 @@ int main(int argc, char *argv[])
}
doMessenger();
fgets(line, STRING_LENGTH, stdin);
line_eval(line);
strcpy(line, "");
}
return 0;