sources/main.cpp

changeset 15
33da84af4bba
parent 14
33b8f428bacb
child 17
50341dec533e
equal deleted inserted replaced
14:33b8f428bacb 15:33da84af4bba
41 main (int argc, char* argv[]) -> int 41 main (int argc, char* argv[]) -> int
42 { 42 {
43 HUFFMAN_Construct(); 43 HUFFMAN_Construct();
44 Interface::initialize(); 44 Interface::initialize();
45 45
46 /* 46 new RCONSession;
47 Vector<RCONSession*> rconsessions; 47 RCONSession::get_session()->set_password ("testpassword");
48 RCONSession* sess = new RCONSession; 48 RCONSession::get_session()->connect (IPAddress (localhost, 10666));
49 sess->set_password ("testpassword");
50 sess->connect (IPAddress (localhost, 10666));
51 rconsessions << sess;
52 */
53 49
54 for (;;) 50 for (;;)
55 { 51 {
56 fd_set fdset; 52 fd_set fdset;
57 int highest = 0; 53 int highest = 0;
58 timeval timeout; 54 timeval timeout;
59 timeout.tv_sec = 0; 55 timeout.tv_sec = 0;
60 timeout.tv_usec = 250000; // 0.25 seconds 56 timeout.tv_usec = 250000; // 0.25 seconds
61 FD_ZERO (&fdset); 57 FD_ZERO (&fdset);
62 FD_SET (0, &fdset); 58 FD_SET (0, &fdset);
59 RCONSession* session = RCONSession::get_session();
63 60
64 /* 61 if (session)
65 for (RCONSession* session : rconsessions)
66 { 62 {
67 int fd = session->socket()->file_descriptor(); 63 int fd = session->socket()->file_descriptor();
68 highest = max (highest, fd); 64 highest = max (highest, fd);
69 FD_SET (fd, &fdset); 65 FD_SET (fd, &fdset);
70 } 66 }
71 */
72 67
73 select (highest + 1, &fdset, nullptr, nullptr, &timeout); 68 select (highest + 1, &fdset, nullptr, nullptr, &timeout);
74 69
75 if (FD_ISSET (0, &fdset)) 70 if (FD_ISSET (0, &fdset))
76 // stdin is ready, what's incoming? 71 // stdin is ready, what's incoming?
77 Interface::handle_input(); 72 Interface::handle_input();
78 73
79 /* 74 if (session)
80 for (RCONSession* session : rconsessions)
81 session->tick(); 75 session->tick();
82 */
83 } 76 }
84 77
85 return EXIT_SUCCESS; 78 return EXIT_SUCCESS;
86 } 79 }

mercurial