mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Added doMessenger() to the loop and connecting to the bootstrap node
This commit is contained in:
parent
5441562e11
commit
b3e5da125c
|
@ -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();
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include <ncurses.h>
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "../core/Messenger.h"
|
||||
#define STRING_LENGTH 256
|
||||
#define HISTORY 50
|
||||
|
|
Loading…
Reference in New Issue
Block a user