From b3e5da125c6294c749fb57e4c7d07649b9ab4afb Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sat, 13 Jul 2013 23:27:52 +0100 Subject: Added doMessenger() to the loop and connecting to the bootstrap node --- testing/nTox.c | 30 +++++++++++++++++++++--------- testing/nTox.h | 3 +++ 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'testing') diff --git a/testing/nTox.c b/testing/nTox.c index 8d2ec1dd..de37b6f7 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -149,6 +149,10 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) } int main(int argc, char *argv[]) { + if (argc < 4) { + printf("usage %s ip port public_key (of the DHT bootstrap node)\n", argv[0]); + exit(0); + } int c; initMessenger(); m_callback_friendrequest(print_request); @@ -178,16 +182,24 @@ int main(int argc, char *argv[]) new_lines(idstring0); do_refresh(); strcpy(line, ""); - while((c=getch())!=27) { - getmaxyx(stdscr,y,x); - if (c == '\n') { - line_eval(lines, line); - strcpy(line, ""); - } else if (c == 127) { - line[strlen(line)-1] = '\0'; - } else if (isalnum(c) || ispunct(c) || c == ' ') { - strcpy(line,appender(line, (char) c)); + IP_Port bootstrap_ip_port; + bootstrap_ip_port.port = htons(atoi(argv[2])); + bootstrap_ip_port.ip.i = inet_addr(argv[1]); + DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); + while(true) { + c=getch(); + if (c != 27) { + getmaxyx(stdscr,y,x); + if (c == '\n') { + line_eval(lines, line); + strcpy(line, ""); + } else if (c == 127) { + line[strlen(line)-1] = '\0'; + } else if (isalnum(c) || ispunct(c) || c == ' ') { + strcpy(line,appender(line, (char) c)); + } } + doMessenger(); do_refresh(); } endwin(); diff --git a/testing/nTox.h b/testing/nTox.h index fea735db..432e0274 100644 --- a/testing/nTox.h +++ b/testing/nTox.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include "../core/Messenger.h" #define STRING_LENGTH 256 #define HISTORY 50 -- cgit v1.2.3