Panda3D

Loading...
Searching...
No Matches
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 {
33PUBLISHED:
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
ConnectionReader::ConnectionReader
ConnectionReader(ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
Creates a new ConnectionReader with the indicated number of threads to handle requests.
Definition connectionReader.cxx:89
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::data_available
bool data_available()
Returns true if a datagram is available on the queue; call get_data() to extract the datagram.
Definition recentConnectionReader.cxx:47
RecentConnectionReader::get_data
bool get_data(NetDatagram &result)
If a previous call to data_available() returned true, this function will return the datagram that has...
Definition recentConnectionReader.cxx:60
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.