sources/main.cpp

changeset 72
1b9c53e0c846
parent 59
00a084f8ed26
child 73
07dda51a7a8e
equal deleted inserted replaced
71:4f7c2c944637 72:1b9c53e0c846
46 { 46 {
47 fprintf (stderr, "usage: %s\nusage: %s <address> <password>\n", argv[0], argv[0]); 47 fprintf (stderr, "usage: %s\nusage: %s <address> <password>\n", argv[0], argv[0]);
48 return EXIT_FAILURE; 48 return EXIT_FAILURE;
49 } 49 }
50 50
51 Interface::initialize(); 51 Interface iface;
52 52
53 if (argc == 3) 53 if (argc == 3)
54 Interface::connect (argv[1], argv[2]); 54 iface.connect (argv[1], argv[2]);
55 55
56 try 56 try
57 { 57 {
58 for (;;) 58 for (;;)
59 { 59 {
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 67
68 { 68 int fd = iface.get_session()->socket()->file_descriptor();
69 int fd = RCONSession::get_session()->socket()->file_descriptor(); 69 highest = max (highest, fd);
70 highest = max (highest, fd); 70 FD_SET (fd, &fdset);
71 FD_SET (fd, &fdset);
72 }
73 71
74 select (highest + 1, &fdset, nullptr, nullptr, &timeout); 72 select (highest + 1, &fdset, nullptr, nullptr, &timeout);
75 73
76 if (FD_ISSET (0, &fdset)) 74 if (FD_ISSET (0, &fdset))
75 {
77 // stdin is ready, what's incoming? 76 // stdin is ready, what's incoming?
78 Interface::handle_input(); 77 iface.handle_input();
78 }
79 79
80 RCONSession::get_session()->tick(); 80 iface.get_session()->tick();
81 Interface::render(); 81 iface.render();
82 } 82 }
83 } 83 }
84 catch (const Exitception&) {} 84 catch (const Exitception&) {}
85 85
86 RCONSession::get_session()->disconnect(); 86 iface.get_session()->disconnect();
87 return EXIT_SUCCESS; 87 return EXIT_SUCCESS;
88 } 88 }

mercurial