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,16 +182,24 @@ 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;
getmaxyx(stdscr,y,x); bootstrap_ip_port.port = htons(atoi(argv[2]));
if (c == '\n') { bootstrap_ip_port.ip.i = inet_addr(argv[1]);
line_eval(lines, line); DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
strcpy(line, ""); while(true) {
} else if (c == 127) { c=getch();
line[strlen(line)-1] = '\0'; if (c != 27) {
} else if (isalnum(c) || ispunct(c) || c == ' ') { getmaxyx(stdscr,y,x);
strcpy(line,appender(line, (char) c)); 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(); 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