| 31 #include <time.h> |
31 #include <time.h> |
| 32 #include <sys/select.h> |
32 #include <sys/select.h> |
| 33 #include "main.h" |
33 #include "main.h" |
| 34 #include "network/rconsession.h" |
34 #include "network/rconsession.h" |
| 35 #include "huffman/huffman.h" |
35 #include "huffman/huffman.h" |
| 36 |
36 #include "interface.h" |
| 37 // ------------------------------------------------------------------------------------------------- |
|
| 38 // |
|
| 39 FUNCTION handle_input() -> void |
|
| 40 { |
|
| 41 int ch = getch(); |
|
| 42 } |
|
| 43 |
37 |
| 44 // ------------------------------------------------------------------------------------------------- |
38 // ------------------------------------------------------------------------------------------------- |
| 45 // |
39 // |
| 46 FUNCTION |
40 FUNCTION |
| 47 main (int argc, char* argv[]) -> int |
41 main (int argc, char* argv[]) -> int |
| 48 { |
42 { |
| 49 HUFFMAN_Construct(); |
43 HUFFMAN_Construct(); |
| |
44 Interface::initialize(); |
| |
45 |
| 50 /* |
46 /* |
| 51 ::initscr(); |
|
| 52 ::start_color(); |
|
| 53 ::raw(); |
|
| 54 ::keypad (stdscr, true); |
|
| 55 ::noecho(); |
|
| 56 ::refresh(); |
|
| 57 ::timeout (0); |
|
| 58 */ |
|
| 59 Vector<RCONSession*> rconsessions; |
47 Vector<RCONSession*> rconsessions; |
| 60 RCONSession* sess = new RCONSession; |
48 RCONSession* sess = new RCONSession; |
| 61 sess->set_password ("testpassword"); |
49 sess->set_password ("testpassword"); |
| 62 sess->connect (IPAddress (localhost, 10666)); |
50 sess->connect (IPAddress (localhost, 10666)); |
| 63 rconsessions << sess; |
51 rconsessions << sess; |
| |
52 */ |
| 64 |
53 |
| 65 for (;;) |
54 for (;;) |
| 66 { |
55 { |
| 67 fd_set fdset; |
56 fd_set fdset; |
| 68 int highest = 0; |
57 int highest = 0; |
| 69 timeval timeout; |
58 timeval timeout; |
| 70 timeout.tv_sec = 0; |
59 timeout.tv_sec = 0; |
| 71 timeout.tv_usec = 250000; // 0.25 seconds |
60 timeout.tv_usec = 250000; // 0.25 seconds |
| 72 FD_ZERO (&fdset); |
61 FD_ZERO (&fdset); |
| 73 //FD_SET (0, &fdset); |
62 FD_SET (0, &fdset); |
| 74 |
63 |
| |
64 /* |
| 75 for (RCONSession* session : rconsessions) |
65 for (RCONSession* session : rconsessions) |
| 76 { |
66 { |
| 77 int fd = session->socket()->file_descriptor(); |
67 int fd = session->socket()->file_descriptor(); |
| 78 highest = max (highest, fd); |
68 highest = max (highest, fd); |
| 79 FD_SET (fd, &fdset); |
69 FD_SET (fd, &fdset); |
| 80 } |
70 } |
| |
71 */ |
| 81 |
72 |
| 82 select (highest + 1, &fdset, nullptr, nullptr, &timeout); |
73 select (highest + 1, &fdset, nullptr, nullptr, &timeout); |
| 83 |
74 |
| |
75 if (FD_ISSET (0, &fdset)) |
| |
76 // stdin is ready, what's incoming? |
| |
77 Interface::handle_input(); |
| |
78 |
| 84 /* |
79 /* |
| 85 if (FD_ISSET (0, &fdset)) |
|
| 86 { |
|
| 87 // stdin is ready, what's incoming? |
|
| 88 handle_input(); |
|
| 89 } |
|
| 90 */ |
|
| 91 |
|
| 92 for (RCONSession* session : rconsessions) |
80 for (RCONSession* session : rconsessions) |
| 93 session->tick(); |
81 session->tick(); |
| |
82 */ |
| 94 } |
83 } |
| 95 |
84 |
| 96 endwin(); |
|
| 97 return EXIT_SUCCESS; |
85 return EXIT_SUCCESS; |
| 98 } |
86 } |