Panda3D

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