Added doMessenger() to the loop and connecting to the bootstrap node

This commit is contained in:
Oliver Hunt 2013-07-13 23:27:52 +01:00
parent 5441562e11
commit b3e5da125c
2 changed files with 24 additions and 9 deletions

View File

@ -149,6 +149,10 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length)
} }
int main(int argc, char *argv[]) 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; int c;
initMessenger(); initMessenger();
m_callback_friendrequest(print_request); m_callback_friendrequest(print_request);
@ -178,7 +182,13 @@ int main(int argc, char *argv[])
new_lines(idstring0); new_lines(idstring0);
do_refresh(); do_refresh();
strcpy(line, ""); strcpy(line, "");
while((c=getch())!=27) { 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); getmaxyx(stdscr,y,x);
if (c == '\n') { if (c == '\n') {
line_eval(lines, line); line_eval(lines, line);
@ -188,6 +198,8 @@ int main(int argc, char *argv[])
} else if (isalnum(c) || ispunct(c) || c == ' ') { } else if (isalnum(c) || ispunct(c) || c == ' ') {
strcpy(line,appender(line, (char) c)); strcpy(line,appender(line, (char) c));
} }
}
doMessenger();
do_refresh(); do_refresh();
} }
endwin(); endwin();

View File

@ -7,6 +7,9 @@
#include <ncurses.h> #include <ncurses.h>
#include <curses.h> #include <curses.h>
#include <ctype.h> #include <ctype.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "../core/Messenger.h" #include "../core/Messenger.h"
#define STRING_LENGTH 256 #define STRING_LENGTH 256
#define HISTORY 50 #define HISTORY 50