Panda3D
|
00001 // Filename: pStatListener.cxx 00002 // Created by: drose (09Jul00) 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 #include "pStatListener.h" 00016 #include "pStatServer.h" 00017 #include "pStatReader.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: PStatListener::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 PStatListener:: 00025 PStatListener(PStatServer *manager) : 00026 ConnectionListener(manager, manager->is_thread_safe() ? 1 : 0), 00027 _manager(manager) 00028 { 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: PStatListener::connection_opened 00033 // Access: Protected, Virtual 00034 // Description: An internal function called by ConnectionListener() 00035 // when a new TCP connection has been established. 00036 //////////////////////////////////////////////////////////////////// 00037 void PStatListener:: 00038 connection_opened(const PT(Connection) &, 00039 const NetAddress &address, 00040 const PT(Connection) &new_connection) { 00041 PStatMonitor *monitor = _manager->make_monitor(); 00042 if (monitor == (PStatMonitor *)NULL) { 00043 nout << "Couldn't create monitor!\n"; 00044 return; 00045 } 00046 00047 nout << "Got new connection from " << address << "\n"; 00048 00049 // Make sure this connection doesn't queue up TCP packets we write 00050 // to it. 00051 new_connection->set_collect_tcp(false); 00052 00053 PStatReader *reader = new PStatReader(_manager, monitor); 00054 _manager->add_reader(new_connection, reader); 00055 reader->set_tcp_connection(new_connection); 00056 }