Panda3D
 All Classes Functions Variables Enumerations
recentConnectionReader.h
1 // Filename: recentConnectionReader.h
2 // Created by: drose (23Jun00)
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 RECENTCONNECTIONREADER_H
16 #define RECENTCONNECTIONREADER_H
17 
18 #include "pandabase.h"
19 
20 #include "connectionReader.h"
21 #include "netDatagram.h"
22 #include "lightMutex.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : RecentConnectionReader
26 // Description : This flavor of ConnectionReader will read from its
27 // sockets and retain only the single most recent
28 // datagram for inspection by client code. It's useful
29 // particularly for reading telemetry-type data from UDP
30 // sockets where you don't care about getting every last
31 // socket, and in fact if the sockets are coming too
32 // fast you'd prefer to skip some of them.
33 //
34 // This class will always create one thread for itself.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_NET RecentConnectionReader : public ConnectionReader {
37 PUBLISHED:
39  virtual ~RecentConnectionReader();
40 
41  bool data_available();
42  bool get_data(NetDatagram &result);
43  bool get_data(Datagram &result);
44 
45 protected:
46  virtual void receive_datagram(const NetDatagram &datagram);
47 
48 private:
49  bool _available;
50  Datagram _datagram;
51  LightMutex _mutex;
52 };
53 
54 #endif
55 
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:43
The primary interface to the low-level networking layer in this package.
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
This flavor of ConnectionReader will read from its sockets and retain only the single most recent dat...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:45
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43