/** * Adds a connection to the list. The connection will setup some listeners so that when certain * events occur, the connection is properly recorded and sets in the connection list for future * references. The connection will not be added if the connection is already in the list. * * @return true if connection added successfully, false otherwise */ public boolean addConnection(GnutellaConnection conn, GnutellaConnectionModel cmodel) { if (shutdown) return false; // check if connection reference already exists // if so, ignore. Otherwise, add it. // The connection equality is not tested on connection model, // but on the connection object itself if (activeConnections.contains(conn)) return false; // check whether a connection to the IP is already made // if so, there is no need to duplicate the connection if (ipList.containsKey(cmodel.getHostAddress())) return false; conn.addConnectionListener(listConnListener); return true; }