00001 // Filename: queuedConnectionListener.h 00002 // Created by: drose (09Feb00) 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 QUEUEDCONNECTIONLISTENER_H 00016 #define QUEUEDCONNECTIONLISTENER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "connectionListener.h" 00021 #include "connection.h" 00022 #include "netAddress.h" 00023 #include "queuedReturn.h" 00024 #include "pdeque.h" 00025 00026 00027 class EXPCL_PANDA_NET ConnectionListenerData { 00028 public: 00029 // We need these methods to make VC++ happy when we try to 00030 // instantiate the template, below. They don't do anything useful. 00031 INLINE bool operator == (const ConnectionListenerData &other) const; 00032 INLINE bool operator != (const ConnectionListenerData &other) const; 00033 INLINE bool operator < (const ConnectionListenerData &other) const; 00034 00035 PT(Connection) _rendezvous; 00036 NetAddress _address; 00037 PT(Connection) _new_connection; 00038 }; 00039 00040 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn<ConnectionListenerData>); 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Class : QueuedConnectionListener 00044 // Description : This flavor of ConnectionListener will queue up all 00045 // of the TCP connections it established for later 00046 // detection by the client code. 00047 //////////////////////////////////////////////////////////////////// 00048 class EXPCL_PANDA_NET QueuedConnectionListener : public ConnectionListener, 00049 public QueuedReturn<ConnectionListenerData> { 00050 PUBLISHED: 00051 QueuedConnectionListener(ConnectionManager *manager, int num_threads); 00052 virtual ~QueuedConnectionListener(); 00053 00054 BLOCKING bool new_connection_available(); 00055 bool get_new_connection(PT(Connection) &rendezvous, 00056 NetAddress &address, 00057 PT(Connection) &new_connection); 00058 bool get_new_connection(PT(Connection) &new_connection); 00059 00060 protected: 00061 virtual void connection_opened(const PT(Connection) &rendezvous, 00062 const NetAddress &address, 00063 const PT(Connection) &new_connection); 00064 }; 00065 00066 #include "queuedConnectionListener.I" 00067 00068 #endif 00069