Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PStatReader Class Reference

This is the class that does all the work for handling communications from a single Panda client. More...

#include <pStatReader.h>

Inheritance diagram for PStatReader:

ConnectionReader List of all members.

Public Member Functions

 PStatReader (PStatServer *manager, PStatMonitor *monitor)
 ~PStatReader ()
void close ()
 This will be called by the PStatClientData in response to its close() call.

void set_tcp_connection (Connection *tcp_connection)
 This is intended to be called only once, immediately after construction, by the PStatListener that created it.

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.

bool add_connection (const PointerTo< Connection > &connection)
bool remove_connection (const PointerTo< Connection > &connection)
bool is_connection_ok (const PointerTo< Connection > &connection)
void poll ()
ConnectionManagerget_manager () const
bool is_polling () const
int get_num_threads () const
void set_raw_mode (bool mode)
bool get_raw_mode () const
void shutdown ()
void clear_manager ()
void finish_socket (SocketInfo *sinfo)
virtual void process_incoming_data (SocketInfo *sinfo)
virtual void process_incoming_udp_data (SocketInfo *sinfo)
virtual void process_incoming_tcp_data (SocketInfo *sinfo)
virtual void process_raw_incoming_udp_data (SocketInfo *sinfo)
virtual void process_raw_incoming_tcp_data (SocketInfo *sinfo)

Protected Member Functions

void thread_run ()
SocketInfo * get_next_available_socket (PRIntervalTime timeout, PRInt32 current_thread_index)
void rebuild_poll_list ()

Static Protected Member Functions

void thread_start (void *data)

Protected Attributes

pvector< PRThread * > Threads
pvector< PRPollDesc > Poll
pvector< SocketInfo * > Sockets
bool _raw_mode
bool _shutdown
Threads _threads
PRLock * _startup_mutex
bool _polling
Poll _poll
Sockets _polled_sockets
int _next_index
int _num_results
PRLock * _select_mutex
PRInt32 _currently_polling_thread
Sockets _sockets
Sockets _removed_sockets
bool _reexamine_sockets
PRLock * _sockets_mutex

Private Types

typedef CircBuffer< FrameData,
queued_frame_records
QueuedFrameData

Private Member Functions

string get_hostname ()
 Returns the current machine's hostname.

void send_hello ()
 Sends the initial greeting message to the client.

virtual void receive_datagram (const NetDatagram &datagram)
 Called by the net code whenever a new datagram is detected on a either the TCP or UDP connection.

void handle_client_control_message (const PStatClientControlMessage &message)
 Called when a control message has been received by the client over the TCP connection.

void handle_client_udp_data (const Datagram &datagram)
 Called when a UDP datagram has been received by the client.

void dequeue_frame_data ()
 Called during the idle loop to pull out all the frame data that we might have read while the threaded reader was running.


Private Attributes

PStatServer_manager
PointerTo< PStatMonitor_monitor
ConnectionWriter _writer
PointerTo< Connection_tcp_connection
PointerTo< Connection_udp_connection
int _udp_port
PointerTo< PStatClientData_client_data
string _hostname
QueuedFrameData _queued_frame_data

Friends

class ConnectionManager

Detailed Description

This is the class that does all the work for handling communications from a single Panda client.

It reads sockets received from the client and boils them down into PStatData.

Definition at line 57 of file pStatReader.h.


Member Typedef Documentation

typedef CircBuffer<FrameData, queued_frame_records> PStatReader::QueuedFrameData [private]
 

Definition at line 97 of file pStatReader.h.


Constructor & Destructor Documentation

PStatReader::PStatReader PStatServer manager,
PStatMonitor monitor
 

Definition at line 42 of file pStatReader.cxx.

References _client_data, _monitor, and _udp_port.

PStatReader::~PStatReader  ) 
 

Definition at line 61 of file pStatReader.cxx.

References _manager, _tcp_connection, lost_connection(), and PStatServer::remove_reader().


Member Function Documentation

void PStatReader::close  ) 
 

This will be called by the PStatClientData in response to its close() call.

It will tell the server to let go of the reader so it can shut down its connection.

Definition at line 80 of file pStatReader.cxx.

References _manager, _tcp_connection, _udp_connection, _udp_port, ConnectionReader::add_connection(), PStatServer::get_udp_port(), PointerTo< Connection >::is_null(), ConnectionManager::open_UDP_connection(), and send_hello().

void PStatReader::dequeue_frame_data  )  [private]
 

Called during the idle loop to pull out all the frame data that we might have read while the threaded reader was running.

Definition at line 344 of file pStatReader.cxx.

string PStatReader::get_hostname  )  [private]
 

Returns the current machine's hostname.

Definition at line 166 of file pStatReader.cxx.

References _client_data, _tcp_connection, PStatClientControlMessage::_type, PStatClientControlMessage::decode(), NetDatagram::get_connection(), handle_client_control_message(), handle_client_udp_data(), nout, and PStatClientControlMessage::T_datagram.

void PStatReader::handle_client_control_message const PStatClientControlMessage message  )  [private]
 

Called when a control message has been received by the client over the TCP connection.

Definition at line 242 of file pStatReader.cxx.

References nout.

Referenced by get_hostname().

void PStatReader::handle_client_udp_data const Datagram datagram  )  [private]
 

Called when a UDP datagram has been received by the client.

This should be a single frame's worth of data.

Definition at line 301 of file pStatReader.cxx.

References _client_data, and _monitor.

Referenced by get_hostname().

void PStatReader::idle  ) 
 

Called each frame to do what needs to be done for the monitor's user-defined idle routines.

Definition at line 152 of file pStatReader.cxx.

References _monitor, _udp_port, _writer, and PStatServerControlMessage::T_hello.

void PStatReader::lost_connection  ) 
 

This is called by the PStatServer when it detects that the connection has been lost.

It should clean itself up and shut down nicely.

Definition at line 130 of file pStatReader.cxx.

References _hostname, and ConnectionManager::get_host_name().

Referenced by ~PStatReader().

void PStatReader::receive_datagram const NetDatagram datagram  )  [private, virtual]
 

Called by the net code whenever a new datagram is detected on a either the TCP or UDP connection.

Implements ConnectionReader.

Definition at line 208 of file pStatReader.cxx.

References PStatClientControlMessage::_client_hostname, PStatClientControlMessage::_client_progname, PStatClientControlMessage::_major_version, PStatClientControlMessage::_minor_version, and _monitor.

void PStatReader::send_hello  )  [private]
 

Sends the initial greeting message to the client.

Definition at line 185 of file pStatReader.cxx.

Referenced by close().

void PStatReader::set_tcp_connection Connection tcp_connection  ) 
 

This is intended to be called only once, immediately after construction, by the PStatListener that created it.

It tells the reader about the newly-established TCP connection to a client.

Definition at line 100 of file pStatReader.cxx.

References _client_data, _manager, _monitor, _tcp_connection, _udp_connection, PointerTo< Connection >::clear(), PointerTo< PStatClientData >::clear(), and ConnectionManager::close_connection().


Member Data Documentation

PointerTo< PStatClientData > PStatReader::_client_data [private]
 

Definition at line 87 of file pStatReader.h.

Referenced by get_hostname(), handle_client_udp_data(), PStatReader(), and set_tcp_connection().

string PStatReader::_hostname [private]
 

Definition at line 89 of file pStatReader.h.

Referenced by lost_connection().

PStatServer* PStatReader::_manager [private]
 

Reimplemented from ConnectionReader.

Definition at line 79 of file pStatReader.h.

Referenced by close(), set_tcp_connection(), and ~PStatReader().

PointerTo< PStatMonitor > PStatReader::_monitor [private]
 

Definition at line 80 of file pStatReader.h.

Referenced by handle_client_udp_data(), idle(), PStatReader(), receive_datagram(), and set_tcp_connection().

QueuedFrameData PStatReader::_queued_frame_data [private]
 

Definition at line 98 of file pStatReader.h.

PointerTo< Connection > PStatReader::_tcp_connection [private]
 

Definition at line 83 of file pStatReader.h.

Referenced by close(), get_hostname(), set_tcp_connection(), and ~PStatReader().

PointerTo< Connection > PStatReader::_udp_connection [private]
 

Definition at line 84 of file pStatReader.h.

Referenced by close(), and set_tcp_connection().

int PStatReader::_udp_port [private]
 

Definition at line 85 of file pStatReader.h.

Referenced by close(), idle(), and PStatReader().

ConnectionWriter PStatReader::_writer [private]
 

Definition at line 81 of file pStatReader.h.

Referenced by idle().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:27:52 2003 for Panda-Tool by doxygen1.3