00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PSTATCLIENTIMPL_H
00016 #define PSTATCLIENTIMPL_H
00017
00018 #include "pandabase.h"
00019
00020
00021 #ifdef DO_PSTATS
00022
00023 #include "pStatFrameData.h"
00024 #include "connectionManager.h"
00025 #include "queuedConnectionReader.h"
00026 #include "connectionWriter.h"
00027 #include "netAddress.h"
00028
00029 #include "trueClock.h"
00030 #include "pmap.h"
00031
00032 class PStatClient;
00033 class PStatServerControlMessage;
00034 class PStatCollector;
00035 class PStatCollectorDef;
00036 class PStatThread;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 class EXPCL_PANDA_PSTATCLIENT PStatClientImpl : public ConnectionManager {
00056 public:
00057 PStatClientImpl(PStatClient *client);
00058 ~PStatClientImpl();
00059
00060 INLINE void set_client_name(const string &name);
00061 INLINE string get_client_name() const;
00062 INLINE void set_max_rate(double rate);
00063 INLINE double get_max_rate() const;
00064
00065 INLINE double get_real_time() const;
00066
00067 INLINE void client_main_tick();
00068 bool client_connect(string hostname, int port);
00069 void client_disconnect();
00070 INLINE bool client_is_connected() const;
00071
00072 INLINE void client_resume_after_pause();
00073
00074 void new_frame(int thread_index);
00075
00076 private:
00077 void transmit_frame_data(int thread_index, int frame_number,
00078 const PStatFrameData &frame_data);
00079
00080 void transmit_control_data();
00081
00082 TrueClock *_clock;
00083 double _delta;
00084 double _last_frame;
00085
00086
00087 string get_hostname();
00088 void send_hello();
00089 void report_new_collectors();
00090 void report_new_threads();
00091 void handle_server_control_message(const PStatServerControlMessage &message);
00092
00093 virtual void connection_reset(const PT(Connection) &connection,
00094 bool okflag);
00095
00096 PStatClient *_client;
00097
00098 bool _is_connected;
00099 bool _got_udp_port;
00100
00101 NetAddress _server;
00102 QueuedConnectionReader _reader;
00103 ConnectionWriter _writer;
00104
00105 PT(Connection) _tcp_connection;
00106 PT(Connection) _udp_connection;
00107
00108 int _collectors_reported;
00109 int _threads_reported;
00110
00111 string _hostname;
00112 string _client_name;
00113 double _max_rate;
00114
00115 double _tcp_count_factor;
00116 double _udp_count_factor;
00117 unsigned int _tcp_count;
00118 unsigned int _udp_count;
00119 };
00120
00121 #include "pStatClientImpl.I"
00122
00123 #endif // DO_PSTATS
00124
00125 #endif
00126