| 62 timeval timeout; |
62 timeval timeout; |
| 63 timeout.tv_sec = 0; |
63 timeout.tv_sec = 0; |
| 64 timeout.tv_usec = 250000; // 0.25 seconds |
64 timeout.tv_usec = 250000; // 0.25 seconds |
| 65 FD_ZERO (&fdset); |
65 FD_ZERO (&fdset); |
| 66 FD_SET (0, &fdset); |
66 FD_SET (0, &fdset); |
| 67 RCONSession* session = RCONSession::get_session(); |
|
| 68 |
67 |
| 69 if (session) |
|
| 70 { |
68 { |
| 71 int fd = session->socket()->file_descriptor(); |
69 int fd = RCONSession::get_session()->socket()->file_descriptor(); |
| 72 highest = max (highest, fd); |
70 highest = max (highest, fd); |
| 73 FD_SET (fd, &fdset); |
71 FD_SET (fd, &fdset); |
| 74 } |
72 } |
| 75 |
73 |
| 76 select (highest + 1, &fdset, nullptr, nullptr, &timeout); |
74 select (highest + 1, &fdset, nullptr, nullptr, &timeout); |
| 77 |
75 |
| 78 if (FD_ISSET (0, &fdset)) |
76 if (FD_ISSET (0, &fdset)) |
| 79 // stdin is ready, what's incoming? |
77 // stdin is ready, what's incoming? |
| 80 Interface::handle_input(); |
78 Interface::handle_input(); |
| 81 |
79 |
| 82 if (session) |
80 RCONSession::get_session()->tick(); |
| 83 session->tick(); |
|
| 84 |
|
| 85 Interface::render(); |
81 Interface::render(); |
| 86 } |
82 } |
| 87 } |
83 } |
| 88 catch (const Exitception&) {} |
84 catch (const Exitception&) {} |
| 89 |
85 |
| 90 if (RCONSession::get_session()) |
86 RCONSession::get_session()->disconnect(); |
| 91 RCONSession::get_session()->disconnect(); |
|
| 92 |
|
| 93 return EXIT_SUCCESS; |
87 return EXIT_SUCCESS; |
| 94 } |
88 } |