Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/pstatserver/pStatListener.cxx

Go to the documentation of this file.
00001 // Filename: pStatListener.cxx
00002 // Created by:  drose (09Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "pStatListener.h"
00020 #include "pStatServer.h"
00021 #include "pStatReader.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: PStatListener::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 PStatListener::
00029 PStatListener(PStatServer *manager) :
00030   ConnectionListener(manager, manager->is_thread_safe() ? 1 : 0),
00031   _manager(manager)
00032 {
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: PStatListener::connection_opened
00037 //       Access: Protected, Virtual
00038 //  Description: An internal function called by ConnectionListener()
00039 //               when a new TCP connection has been established.
00040 ////////////////////////////////////////////////////////////////////
00041 void PStatListener::
00042 connection_opened(const PT(Connection) &,
00043                   const NetAddress &address,
00044                   const PT(Connection) &new_connection) {
00045   PStatMonitor *monitor = _manager->make_monitor();
00046   if (monitor == (PStatMonitor *)NULL) {
00047     nout << "Couldn't create monitor!\n";
00048     return;
00049   }
00050 
00051   nout << "Got new connection from " << address << "\n";
00052 
00053   // Make sure this connection doesn't queue up TCP packets we write
00054   // to it.
00055   new_connection->set_collect_tcp(false);
00056 
00057   PStatReader *reader = new PStatReader(_manager, monitor);
00058   _manager->add_reader(new_connection, reader);
00059   reader->set_tcp_connection(new_connection);
00060 }

Generated on Fri May 2 03:21:35 2003 for Panda-Tool by doxygen1.3