Panda3D
pStatListener.cxx
1 // Filename: pStatListener.cxx
2 // Created by: drose (09Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "pStatListener.h"
16 #include "pStatServer.h"
17 #include "pStatReader.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: PStatListener::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 PStatListener::
25 PStatListener(PStatServer *manager) :
26  ConnectionListener(manager, manager->is_thread_safe() ? 1 : 0),
27  _manager(manager)
28 {
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: PStatListener::connection_opened
33 // Access: Protected, Virtual
34 // Description: An internal function called by ConnectionListener()
35 // when a new TCP connection has been established.
36 ////////////////////////////////////////////////////////////////////
37 void PStatListener::
38 connection_opened(const PT(Connection) &,
39  const NetAddress &address,
40  const PT(Connection) &new_connection) {
41  PStatMonitor *monitor = _manager->make_monitor();
42  if (monitor == (PStatMonitor *)NULL) {
43  nout << "Couldn't create monitor!\n";
44  return;
45  }
46 
47  nout << "Got new connection from " << address << "\n";
48 
49  // Make sure this connection doesn't queue up TCP packets we write
50  // to it.
51  new_connection->set_collect_tcp(false);
52 
53  PStatReader *reader = new PStatReader(_manager, monitor);
54  _manager->add_reader(new_connection, reader);
55  reader->set_tcp_connection(new_connection);
56 }
void set_tcp_connection(Connection *tcp_connection)
This is intended to be called only once, immediately after construction, by the PStatListener that cr...
Definition: pStatReader.cxx:83
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:43
This is the class that does all the work for handling communications from a single Panda client...
Definition: pStatReader.h:44
void set_collect_tcp(bool collect_tcp)
Enables or disables "collect-tcp" mode.
Definition: connection.cxx:133
The overall manager of the network connections.
Definition: pStatServer.h:41
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:32
This is a special kind of ConnectionReader that waits for activity on a rendezvous port and accepts a...
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound...
Definition: netAddress.h:27