Panda3D
 All Classes Functions Variables Enumerations
recentConnectionReader.h
00001 // Filename: recentConnectionReader.h
00002 // Created by:  drose (23Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef RECENTCONNECTIONREADER_H
00016 #define RECENTCONNECTIONREADER_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "connectionReader.h"
00021 #include "netDatagram.h"
00022 #include "lightMutex.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : RecentConnectionReader
00026 // Description : This flavor of ConnectionReader will read from its
00027 //               sockets and retain only the single most recent
00028 //               datagram for inspection by client code.  It's useful
00029 //               particularly for reading telemetry-type data from UDP
00030 //               sockets where you don't care about getting every last
00031 //               socket, and in fact if the sockets are coming too
00032 //               fast you'd prefer to skip some of them.
00033 //
00034 //               This class will always create one thread for itself.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA_NET RecentConnectionReader : public ConnectionReader {
00037 PUBLISHED:
00038   RecentConnectionReader(ConnectionManager *manager);
00039   virtual ~RecentConnectionReader();
00040 
00041   bool data_available();
00042   bool get_data(NetDatagram &result);
00043   bool get_data(Datagram &result);
00044 
00045 protected:
00046   virtual void receive_datagram(const NetDatagram &datagram);
00047 
00048 private:
00049   bool _available;
00050   Datagram _datagram;
00051   LightMutex _mutex;
00052 };
00053 
00054 #endif
00055 
 All Classes Functions Variables Enumerations