Panda3D
pStatReader.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 pStatReader.h
10  * @author drose
11  * @date 2000-07-09
12  */
13 
14 #ifndef PSTATREADER_H
15 #define PSTATREADER_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "pStatClientData.h"
20 #include "pStatMonitor.h"
21 
22 #include "connectionReader.h"
23 #include "connectionWriter.h"
24 #include "referenceCount.h"
25 #include "circBuffer.h"
26 
27 class PStatServer;
28 class PStatMonitor;
30 class PStatFrameData;
31 
32 // This is the maximum number of frame records that will be queued up from
33 // this particular client between processing loops.
34 static const int queued_frame_records = 500;
35 
36 /**
37  * This is the class that does all the work for handling communications from a
38  * single Panda client. It reads sockets received from the client and boils
39  * them down into PStatData.
40  */
41 class PStatReader : public ConnectionReader {
42 public:
43  PStatReader(PStatServer *manager, PStatMonitor *monitor);
44  ~PStatReader();
45 
46  void close();
47 
48  void set_tcp_connection(Connection *tcp_connection);
49  void lost_connection();
50  void idle();
51 
53 
54 private:
55  std::string get_hostname();
56  void send_hello();
57 
58  virtual void receive_datagram(const NetDatagram &datagram);
59 
60  void handle_client_control_message(const PStatClientControlMessage &message);
61  void handle_client_udp_data(const Datagram &datagram);
62  void dequeue_frame_data();
63 
64 private:
65  PStatServer *_manager;
66  PT(PStatMonitor) _monitor;
67  ConnectionWriter _writer;
68 
69  PT(Connection) _tcp_connection;
70  PT(Connection) _udp_connection;
71  int _udp_port;
72 
73  PT(PStatClientData) _client_data;
74 
75  std::string _hostname;
76 
77  class FrameData {
78  public:
79  int _thread_index;
80  int _frame_number;
81  PStatFrameData *_frame_data;
82  };
84  QueuedFrameData _queued_frame_data;
85 };
86 
87 #endif
PStatMonitor * get_monitor()
Returns the monitor that this reader serves.
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:40
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_tcp_connection(Connection *tcp_connection)
This is intended to be called only once, immediately after construction, by the PStatListener that cr...
Definition: pStatReader.cxx:72
The data associated with a particular client, but not with any one particular frame or thread: the li...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This kind of message is sent from the client to the server on the TCP socket to establish critical co...
void idle()
Called each frame to do what needs to be done for the monitor's user- defined idle routines.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the class that does all the work for handling communications from a single Panda client.
Definition: pStatReader.h:41
void lost_connection()
This is called by the PStatServer when it detects that the connection has been lost.
Definition: pStatReader.cxx:94
Contains the raw timing and level data for a single frame.
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The overall manager of the network connections.
Definition: pStatServer.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:29
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
void close()
This will be called by the PStatClientData in response to its close() call.
Definition: pStatReader.cxx:61