Panda3D
 All Classes Functions Variables Enumerations
pStatReader.h
1 // Filename: pStatReader.h
2 // Created by: drose (09Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PSTATREADER_H
16 #define PSTATREADER_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "pStatClientData.h"
21 #include "pStatMonitor.h"
22 
23 #include "connectionReader.h"
24 #include "connectionWriter.h"
25 #include "referenceCount.h"
26 #include "circBuffer.h"
27 
28 class PStatServer;
29 class PStatMonitor;
31 class PStatFrameData;
32 
33 // This is the maximum number of frame records that will be queued up
34 // from this particular client between processing loops.
35 static const int queued_frame_records = 500;
36 
37 ////////////////////////////////////////////////////////////////////
38 // Class : PStatReader
39 // Description : This is the class that does all the work for handling
40 // communications from a single Panda client. It reads
41 // sockets received from the client and boils them down
42 // into PStatData.
43 ////////////////////////////////////////////////////////////////////
44 class PStatReader : public ConnectionReader {
45 public:
46  PStatReader(PStatServer *manager, PStatMonitor *monitor);
47  ~PStatReader();
48 
49  void close();
50 
51  void set_tcp_connection(Connection *tcp_connection);
52  void lost_connection();
53  void idle();
54 
56 
57 private:
58  string get_hostname();
59  void send_hello();
60 
61  virtual void receive_datagram(const NetDatagram &datagram);
62 
63  void handle_client_control_message(const PStatClientControlMessage &message);
64  void handle_client_udp_data(const Datagram &datagram);
65  void dequeue_frame_data();
66 
67 private:
68  PStatServer *_manager;
69  PT(PStatMonitor) _monitor;
70  ConnectionWriter _writer;
71 
72  PT(Connection) _tcp_connection;
73  PT(Connection) _udp_connection;
74  int _udp_port;
75 
76  PT(PStatClientData) _client_data;
77 
78  string _hostname;
79 
80  class FrameData {
81  public:
82  int _thread_index;
83  int _frame_number;
84  PStatFrameData *_frame_data;
85  };
87  QueuedFrameData _queued_frame_data;
88 };
89 
90 #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:43
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:83
The data associated with a particular client, but not with any one particular frame or thread: the li...
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...
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:43
This is the class that does all the work for handling communications from a single Panda client...
Definition: pStatReader.h:44
void lost_connection()
This is called by the PStatServer when it detects that the connection has been lost.
Contains the raw timing and level data for a single frame.
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
The overall manager of the network connections.
Definition: pStatServer.h:41
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:32
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
void close()
This will be called by the PStatClientData in response to its close() call.
Definition: pStatReader.cxx:69