Panda3D
Loading...
Searching...
No Matches
pStatClientImpl.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pStatClientImpl.h
10 * @author drose
11 * @date 2004-12-23
12 */
13
14#ifndef PSTATCLIENTIMPL_H
15#define PSTATCLIENTIMPL_H
16
17#include "pandabase.h"
18
19// This class doesn't exist at all unless DO_PSTATS is defined.
20#ifdef DO_PSTATS
21
22#include "pStatFrameData.h"
23#include "connectionManager.h"
25#include "connectionWriter.h"
26#include "netAddress.h"
27
28#include "trueClock.h"
29#include "pmap.h"
30
31class PStatClient;
33class PStatCollector;
35class PStatThread;
36
37/**
38 * This class is the implementation of the actual PStatClient class (which is
39 * just for interface). All of the stuff to manage sending stats up to the
40 * server is handled by this class.
41 *
42 * This separation between PStatClient and PStatClientImpl allows the global
43 * PStatClient to be constructed at static init time, without having to
44 * consult any config variables at that time. We don't actually do any real
45 * work until someone explicitly calls PStatClient::connect().
46 *
47 * This class doesn't exist at all unless DO_PSTATS is defined.
48 */
49class EXPCL_PANDA_PSTATCLIENT PStatClientImpl : public ConnectionManager {
50public:
51 PStatClientImpl(PStatClient *client);
52 ~PStatClientImpl();
53
54 INLINE void set_client_name(const std::string &name);
55 INLINE std::string get_client_name() const;
56 INLINE void set_max_rate(double rate);
57 INLINE double get_max_rate() const;
58
59 INLINE double get_real_time() const;
60
61 INLINE void client_main_tick();
62 bool client_connect(std::string hostname, int port);
63 void client_disconnect();
64 INLINE bool client_is_connected() const;
65
66 INLINE void client_resume_after_pause();
67
68 void new_frame(int thread_index);
69 void add_frame(int thread_index, const PStatFrameData &frame_data);
70
71private:
72 void transmit_frame_data(int thread_index, int frame_number,
73 const PStatFrameData &frame_data);
74
75 void transmit_control_data();
76
77 TrueClock *_clock;
78 double _delta;
79 double _last_frame;
80
81 // Networking stuff
82 std::string get_hostname();
83 void send_hello();
84 void report_new_collectors();
85 void report_new_threads();
86 void handle_server_control_message(const PStatServerControlMessage &message);
87
88 virtual void connection_reset(const PT(Connection) &connection,
89 bool okflag);
90
91 PStatClient *_client;
92
93 bool _is_connected;
94 bool _got_udp_port;
95
96 NetAddress _server;
98 ConnectionWriter _writer;
99
100 PT(Connection) _tcp_connection;
101 PT(Connection) _udp_connection;
102
103 int _collectors_reported;
104 int _threads_reported;
105
106 std::string _hostname;
107 std::string _client_name;
108 double _max_rate;
109
110 double _tcp_count_factor;
111 double _udp_count_factor;
112 unsigned int _tcp_count;
113 unsigned int _udp_count;
114};
115
116#include "pStatClientImpl.I"
117
118#endif // DO_PSTATS
119
120#endif
The primary interface to the low-level networking layer in this package.
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
Represents a single TCP or UDP socket for input or output.
Definition connection.h:29
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition netAddress.h:25
Manages the communications to report statistics via a network connection to a remote PStatServer.
Defines the details about the Collectors: the name, the suggested color, etc.
A lightweight class that represents a single element that may be timed and/or counted via stats.
Contains the raw timing and level data for a single frame.
This kind of message is sent from the server to the client on the TCP socket to establish critical co...
A lightweight class that represents a single thread of execution to PStats.
Definition pStatThread.h:28
This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for...
An interface to whatever real-time clock we might have available in the current environment.
Definition trueClock.h:33
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.