55 PT(
Connection) rendezvous = open_TCP_server_rendezvous(port, 5);
57 if (rendezvous.is_null()) {
65 if (_next_udp_port == 0) {
66 _next_udp_port = port + 1;
84 while (!_lost_readers.empty()) {
86 _lost_readers.pop_back();
91 while (!_removed_readers.empty()) {
93 _removed_readers.pop_back();
99 Readers::const_iterator ri = _readers.begin();
100 while (ri != _readers.end()) {
103 Readers::const_iterator rnext = ri;
125 while (interrupt_flag ==
nullptr || !*interrupt_flag) {
136 _readers[connection] = reader;
144 Readers::iterator ri;
145 ri = _readers.find(connection);
146 if (ri == _readers.end() || (*ri).second != reader) {
147 nout <<
"Attempt to remove undefined reader.\n";
150 _removed_readers.push_back(reader);
161 if (_available_udp_ports.empty()) {
162 return _next_udp_port++;
164 int udp_port = _available_udp_ports.front();
165 _available_udp_ports.pop_front();
174 _available_udp_ports.push_back(port);
182 return _user_guide_bars.size();
190 nassertr(n >= 0 && n < (
int)_user_guide_bars.size(), 0.0f);
191 return _user_guide_bars[n];
199 nassertv(n >= 0 && n < (
int)_user_guide_bars.size());
200 _user_guide_bars[n] = height;
201 user_guide_bars_changed();
209 int n = (int)_user_guide_bars.size();
210 _user_guide_bars.push_back(height);
211 user_guide_bars_changed();
222 nassertv(n >= 0 && n < (
int)_user_guide_bars.size());
223 _user_guide_bars.erase(_user_guide_bars.begin() + n);
224 user_guide_bars_changed();
234 GuideBars::const_iterator gbi;
235 for (gbi = _user_guide_bars.begin();
236 gbi != _user_guide_bars.end();
238 double height = (*gbi);
239 if (height >= from_height && height <= to_height) {
240 return (
int)(gbi - _user_guide_bars.begin());
251 user_guide_bars_changed() {
252 Readers::iterator ri;
253 for (ri = _readers.begin(); ri != _readers.end(); ++ri) {
254 (*ri).second->get_monitor()->user_guide_bars_changed();
278 connection_reset(
const PT(
Connection) &connection,
bool okflag) {
280 close_connection(connection);
282 Readers::iterator ri;
283 ri = _readers.find(connection);
284 if (ri != _readers.end()) {
291 _lost_readers.push_back(reader);
void poll()
Explicitly polls the available sockets to see if any of them have any noise.
bool add_connection(Connection *connection)
Adds a new socket to the list of sockets the ConnectionReader will monitor.
Represents a single TCP or UDP socket for input or output.
This is the TCP rendezvous socket listener.
This is the class that does all the work for handling communications from a single Panda client.
void lost_connection()
This is called by the PStatServer when it detects that the connection has been lost.
void idle()
Called each frame to do what needs to be done for the monitor's user- defined idle routines.
void remove_user_guide_bar(int n)
Removes the user guide bar with the indicated index number.
int add_user_guide_bar(double height)
Creates a new user guide bar and returns its index number.
virtual bool is_thread_safe()
This should be redefined to return true in derived classes that want to deal with multithreaded reade...
void main_loop(bool *interrupt_flag=nullptr)
An alternative to repeatedly calling poll(), this function yields control of the program to the PStat...
void move_user_guide_bar(int n, double height)
Adjusts the height of the nth user-defined guide bar.
void remove_reader(Connection *connection, PStatReader *reader)
Removes the indicated reader.
void poll()
Checks for any network activity and handles it, if appropriate, and then returns.
int get_num_user_guide_bars() const
Returns the current number of user-defined guide bars.
void add_reader(Connection *connection, PStatReader *reader)
Adds the newly-created PStatReader to the list of currently active readers.
bool listen(int port=-1)
Establishes a port number that the manager will listen on for TCP connections.
void release_udp_port(int port)
Indicates that the given UDP port is once again free for use.
int get_udp_port()
Returns a new port number that will probably be free to use as a UDP port.
double get_user_guide_bar_height(int n) const
Returns the height of the nth user-defined guide bar.
int find_user_guide_bar(double from_height, double to_height) const
Returns the index number of the first user guide bar found whose height is within the indicated range...
static void sleep(double seconds)
Suspends the current thread for at least the indicated amount of time.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.