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

pandatool/src/pstatserver/pStatReader.h

Go to the documentation of this file.
00001 // Filename: pStatReader.h
00002 // Created by:  drose (09Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PSTATREADER_H
00020 #define PSTATREADER_H
00021 
00022 #include <pandatoolbase.h>
00023 
00024 #include "pStatClientData.h"
00025 #include "pStatMonitor.h"
00026 
00027 #include <connectionReader.h>
00028 #include <connectionWriter.h>
00029 #include <referenceCount.h>
00030 #include <circBuffer.h>
00031 
00032 class PStatServer;
00033 class PStatMonitor;
00034 class PStatClientControlMessage;
00035 class PStatFrameData;
00036 
00037 // This is the maximum number of frame records that will be queued up
00038 // from this particular client between processing loops.
00039 static const int queued_frame_records = 500;
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //       Class : PStatReader
00043 // Description : This is the class that does all the work for handling
00044 //               communications from a single Panda client.  It reads
00045 //               sockets received from the client and boils them down
00046 //               into PStatData.
00047 ////////////////////////////////////////////////////////////////////
00048 class PStatReader : public ConnectionReader {
00049 public:
00050   PStatReader(PStatServer *manager, PStatMonitor *monitor);
00051   ~PStatReader();
00052 
00053   void close();
00054 
00055   void set_tcp_connection(Connection *tcp_connection);
00056   void lost_connection();
00057   void idle();
00058 
00059 private:
00060   string get_hostname();
00061   void send_hello();
00062 
00063   virtual void receive_datagram(const NetDatagram &datagram);
00064 
00065   void handle_client_control_message(const PStatClientControlMessage &message);
00066   void handle_client_udp_data(const Datagram &datagram);
00067   void dequeue_frame_data();
00068 
00069 private:
00070   PStatServer *_manager;
00071   PT(PStatMonitor) _monitor;
00072   ConnectionWriter _writer;
00073 
00074   PT(Connection) _tcp_connection;
00075   PT(Connection) _udp_connection;
00076   int _udp_port;
00077 
00078   PT(PStatClientData) _client_data;
00079 
00080   string _hostname;
00081 
00082   class FrameData {
00083   public:
00084     int _thread_index;
00085     int _frame_number;
00086     PStatFrameData *_frame_data;
00087   };
00088   typedef CircBuffer<FrameData, queued_frame_records> QueuedFrameData;
00089   QueuedFrameData _queued_frame_data;
00090 };
00091 
00092 #endif

Generated on Fri May 2 03:21:38 2003 for Panda-Tool by doxygen1.3