This method adds connections to the session both on a connection#created and on a session#read. In the case of session#read sessionRead is set to true and we include our own connection.
430898
function (connection, sessionRead) {
        connection = OT.Connection.fromHash(connection);
        if (sessionRead || session.connection && connection.id !== session.connection.id) {
          session.connections.add( connection );
          delayedSessionEvents.triggerConnectionCreated(connection);
        }

        OT.$.forEach(OT.$.keys(unconnectedStreams), function(streamId) {
          var stream = unconnectedStreams[streamId];
          if (stream && connection.id === stream.connection.id) {
            // dispatch streamCreated event now that the connectionCreated has been dispatched
            parseAndAddStreamToSession(stream, session);
            delete unconnectedStreams[stream.id];
            
            var payload = {
              debug: sessionRead ? 'connection came in session#read' :
                'connection came in connection#created',
              streamId : stream.id,
              connectionId : connection.id
            };
            session.logEvent('streamCreated', 'warning', payload);
          }
        });
        
        return connection;
      }
512748
protected void addConnection(Socket socket) throws IOException {
        FTPConnection con = createConnection(socket);

        synchronized(listeners) {
            for(IFTPListener l : listeners) {
                l.onConnected(con);
            }
        }
        synchronized(connections) {
            connections.add(con);
        }
    }
610263
public void add(Reader reader) throws IOException
    {
        BufferedReader buffered = new BufferedReader(reader);
        String line = buffered.readLine();
        while (line != null)
        {
            String[] split = line.split(delimiter);
            if (split.length != 2)
                throw new IllegalArgumentException();
            add(split[0].trim(), MentionType.getType(split[1].trim()));
            line = buffered.readLine();
        }
        // System.out.println("Size is now " + entities.size());
    }
678801
public void setConnections(java.util.Collection<Connection> connections) {
        if (connections == null) {
            this.connections = null;
            return;
        }

        this.connections = new java.util.ArrayList<Connection>(connections);
    }
893060
@Override
    public void addReadInterest(){
        if(transportIn.peekIn==this)
            transportIn.peekInInterested = true;
        if(appReadBuffers[appReadBuffers.length-1].hasRemaining()
                || engine.isInboundDone()
                || (peerReadBuffer!=null && peerReadBuffer.hasRemaining() && !unwrapUnderflow))
            transportIn.wakeupReader();
        else{
            if(selfInterests==0)
                peerIn.addReadInterest();
            else{
                if((selfInterests&OP_READ)!=0)
                    peerIn.addReadInterest();
                if((selfInterests&OP_WRITE)!=0)
                    peerOut.addWriteInterest();
            }
        }
    }
318644
def addReadGroupSet(self, readGroupSet):
        
        id_ = readGroupSet.getId()
        self._readGroupSetIdMap[id_] = readGroupSet
        self._readGroupSetNameMap[readGroupSet.getLocalId()] = readGroupSet
        self._readGroupSetIds.append(id_)
225719
public void addConnection(ServerSentEventConnection connection) {
        Objects.requireNonNull(connection, Required.CONNECTION.toString());

        final String url = RequestUtils.getServerSentEventURL(connection);
        Set<ServerSentEventConnection> uriConnections = getConnections(url);
        if (uriConnections == null) {
            uriConnections = new HashSet<>();
            uriConnections.add(connection);
        } else {
            uriConnections.add(connection);
        }
        setConnections(url, uriConnections);
    }
353280
public void addConnection (Connection connection) {
		if (connection == null) throw new IllegalArgumentException("connection cannot be null.");

		synchronized (connectionsLock) {
			Connection[] newConnections = new Connection[connections.length + 1];
			newConnections[0] = connection;
			System.arraycopy(connections, 0, newConnections, 1, connections.length);
			connections = newConnections;
		}

		connection.addListener(invokeListener);

		if (TRACE) trace("kryonet", "Added connection to ObjectSpace: " + connection);
	}
342277
def on_connection_open(self, unused_connection):
        
        self._logger.info('Connection opened')
        self.add_on_connection_close_callback()
        self.open_channel()
274265
public void addNewConnective() {

        String fieldName = this.fieldName;
        String fieldType = this.fieldType;
        String factType = this.factType;

        if ( this.connectives == null ) {
            this.connectives = new ConnectiveConstraint[]{ new ConnectiveConstraint( factType,
                                                                                     fieldName,
                                                                                     fieldType ) };
        } else {
            final ConnectiveConstraint[] newList = new ConnectiveConstraint[ this.connectives.length + 1 ];
            for ( int i = 0; i < this.connectives.length; i++ ) {
                newList[ i ] = this.connectives[ i ];
            }
            newList[ this.connectives.length ] = new ConnectiveConstraint( factType,
                                                                           fieldName,
                                                                           fieldType );
            this.connectives = newList;
        }
    }
1015184
protected function attachReadStream()
    {
        $this->ThrowOnConnectionInvalid();
        $this->loop->addReadStream($this->connection, function () {
            $this->readToBuffer();
        });
    }
684877
@Override
  public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException {
    checkWaitingConnection();
    if (currentReadOnlyAsked != mustBeReadOnly) {
      proxy.lock.lock();
      try {
        // another thread updated state
        if (currentReadOnlyAsked == mustBeReadOnly) {
          return;
        }
        currentReadOnlyAsked = mustBeReadOnly;
        if (currentReadOnlyAsked) {
          if (currentProtocol == null) {
            //switching to secondary connection
            currentProtocol = this.secondaryProtocol;
          } else if (currentProtocol.isMasterConnection()) {
            //must change to replica connection
            if (!isSecondaryHostFail()) {
              try {
                //switching to secondary connection
                syncConnection(this.masterProtocol, this.secondaryProtocol);
                currentProtocol = this.secondaryProtocol;
                //current connection is now secondary
                return;
              } catch (SQLException e) {
                //switching to secondary connection failed
                if (setSecondaryHostFail()) {
                  addToBlacklist(secondaryProtocol.getHostAddress());
                }
              }
            }
            //stay on master connection, since slave connection is fail
            FailoverLoop.addListener(this);
          }
        } else {
          if (currentProtocol == null) {
            //switching to master connection
            currentProtocol = this.masterProtocol;
          } else if (!currentProtocol.isMasterConnection()) {
            //must change to master connection
            if (!isMasterHostFail()) {
              try {
                //switching to master connection
                syncConnection(this.secondaryProtocol, this.masterProtocol);
                currentProtocol = this.masterProtocol;
                //current connection is now master
                return;
              } catch (SQLException e) {
                //switching to master connection failed
                if (setMasterHostFail()) {
                  addToBlacklist(masterProtocol.getHostAddress());
                }
              }
            } else if (urlParser.getOptions().allowMasterDownConnection) {
              currentProtocol = null;
              return;
            }

            try {
              reconnectFailedConnection(new SearchFilter(true, false));
              handleFailLoop();

            } catch (SQLException e) {
              //stop failover, since we will throw a connection exception that will close the connection.
              FailoverLoop.removeListener(this);
              HostAddress failHost =
                  (this.masterProtocol != null) ? this.masterProtocol.getHostAddress() : null;
              throwFailoverMessage(failHost, true, new SQLException("master connection failed"),
                  false);
            }

            if (!isMasterHostFail()) {
              //connection established, no need to send Exception !
              //switching to master connection
              try {
                syncConnection(this.secondaryProtocol, this.masterProtocol);
                currentProtocol = this.masterProtocol;
              } catch (SQLException e) {
                //switching to master connection failed
                if (setMasterHostFail()) {
                  addToBlacklist(masterProtocol.getHostAddress());
                }
              }
            } else {
              currentReadOnlyAsked = !mustBeReadOnly;
              HostAddress failHost =
                  (this.masterProtocol != null) ? this.masterProtocol.getHostAddress() : null;
              throwFailoverMessage(failHost, true, new SQLException("master connection failed"),
                  false);
            }

          }
        }
      } finally {
        proxy.lock.unlock();
      }
    }
  }
307064
private void addConnection() throws SQLException {

    //create new connection
    Protocol protocol = Utils.retrieveProxy(urlParser, globalInfo);
    MariaDbConnection connection = new MariaDbConnection(protocol);
    MariaDbPooledConnection pooledConnection = createPoolConnection(connection);

    if (options.staticGlobal) {
      //on first connection load initial state
      if (globalInfo == null) {
        initializePoolGlobalState(connection);
      }
      //set default transaction isolation level to permit resetting to initial state
      connection.setDefaultTransactionIsolation(globalInfo.getDefaultTransactionIsolation());
    } else {
      //set default transaction isolation level to permit resetting to initial state
      connection.setDefaultTransactionIsolation(connection.getTransactionIsolation());
    }

    if (poolState.get() == POOL_STATE_OK
        && totalConnection.incrementAndGet() <= options.maxPoolSize) {
      idleConnections.addFirst(pooledConnection);

      if (logger.isDebugEnabled()) {
        logger.debug("pool {} new physical connection created (total:{}, active:{}, pending:{})",
            poolTag, totalConnection.get(), getActiveConnections(), pendingRequestNumber.get());
      }
      return;
    }

    silentCloseConnection(pooledConnection);
  }
929975
public final void addConnections (final int max) throws Exception {

        if (connections.size() < maxConnections) {
            for (int i = 1; i < max; i++) {
                addNewConnection();
            }
        }
    }
566208
public synchronized void add(int id, SICoreConnection connection) {
        if (tc.isEntryEnabled())
            SibTr.entry(tc, "add", "" + id);
        map.put(id, connection);
        if (tc.isEntryEnabled())
            SibTr.exit(tc, "add");
    }
1211224
protected static function initConnection()
    {
        $readConfig = new DBConfig();
        self::$conn_list = $readConfig->getAllConnection();
        self::$conn_list['db'] = $readConfig->getDefaultConnection();
        self::$conn_name_list = array_keys(self::$conn_list);
    }
715034
private void addConnectionRequest() {
    if (totalConnection.get() < options.maxPoolSize && poolState.get() == POOL_STATE_OK) {

      //ensure to have one worker if was timeout
      connectionAppender.prestartCoreThread();
      connectionAppenderQueue.offer(() -> {

        if ((totalConnection.get() < options.minPoolSize || pendingRequestNumber.get() > 0)
            && totalConnection.get() < options.maxPoolSize) {
          try {
            addConnection();
          } catch (SQLException sqle) {
            //eat
          }
        }
      });
    }
  }