Mark connection as free
@param  ClientConnection $conn Connection
@param  string $url URL
@return void
544854
public function markConnFree(ClientConnection $conn, $url)
    {
        if (!isset($this->servConnFree[$url])) {
            return;
        }
        $this->servConnFree[$url]->attach($conn);
    }
535376
private void remove(PollController conn)
  {
    if (conn == null) {
      return;
    }

    if (_lifecycle.isDestroyed()) {
      return;
    }

    _activeCount.incrementAndGet();

    if (_activeCount.decrementAndGet() == 0 && _lifecycle.isDestroyed()) {
      destroy();
    }
  }
811867
public function handleStop(ConnectionInterface $conn, array $data)
    {
        $connSubscriptions = $this->connStorage->offsetGet($conn);
        $subscription = array_get($connSubscriptions, $data['id']);

        if (!is_null($subscription)) {
            unset($this->subscriptions[$subscription['name']][$subscription['index']]);
            unset($connSubscriptions[$subscription['id']]);
            $this->connStorage->offsetSet($conn, $connSubscriptions);
            $this->callListener(ON_DISCONNECT, [$subscription, $this->rootValue, $this->context]);
        }
    }
964872
function (conn) {
            if (!this.__validateConnectionCB) {
                var ret = new Promise();
                ret.callback(true);
                return ret;
            } else {
                return this.__validateConnectionCB(conn);
            }
        }
56744
public function onUnSubscribe(Conn $conn, $topic)
    {
        $topic->broadcast($conn->resourceId . " has left " . $topic->getId());
    }
892460
private void handleConnectionProperties(URLConnection conn)
    {
        if (pageProperties == null)
        {
            pageProperties = new Hashtable<String, Object>(22);
        }

        String type = conn.getContentType();
        if (type != null)
        {
            // XXX mozno prepisat podla seba, setContentType, len pre text/****
            setContentType(type); // >> XXX putClientProperty("charset",
                                  // charset); !!!
            // charset\s*=[\s'"]*([\-_a-zA-Z0-9]+)[\s'",;]*
            // pageProperties.put("content-type", type);
        }

        pageProperties.put(Document.StreamDescriptionProperty, conn.getURL());

        // String enc = conn.getContentEncoding();
        // if (enc != null) {
        // pageProperties.put("content-encoding", enc);
        // }

        Map<String, List<String>> header = conn.getHeaderFields();

        Set<String> keys = header.keySet();
        Object obj;
        for (String key : keys)
        {
            obj = header.get(key);
            if (key != null && obj != null)
            {
                pageProperties.put(key, obj);
            }
        }

        System.out.println("# pageProperties #");
        for (String k : pageProperties.keySet())
        {
            System.out.println(k + " : " + pageProperties.get(k));
        }

    }
295979
@Override
    public void setConnection(RTMPConnection conn) {
        log.trace("Adding connection: {}", conn);
        int id = conn.getId();
        if (id == -1) {
            log.debug("Connection has unsupported id, using session id hash");
            id = conn.getSessionId().hashCode();
        }
        log.debug("Connection id: {} session id hash: {}", conn.getId(), conn.getSessionId().hashCode());
    }
1186295
public function onClose(ConnectionInterface $conn) {

        // The connection is closed, remove it, as we can no longer send it messages
        $this->clients->detach($conn);

        // pulled data from queues
        $data = $this->queueService->pull([
            // identity for open queue message
                'hash'        =>  md5($this->getIpAddress($conn).$this->getUserAgent($conn)),
            ], function($response) use ($conn) {

            return array_merge($response, [
                'ua'            => $this->getUserAgent($conn),
                'language'      => $this->getLanguage($conn),
                'location'      => $this->getLocation($conn),
                'close'         => time()
            ]);
        });

        // save data to storage
        $this->storageService->add($data);

        echo Messenger::close($this->getIpAddress($conn));

        // end profiler
        if(defined('SONAR_VERBOSE') === true) {
            Profiler::finish();
            Profiler::getProfilingData();
        }
    }
1220761
function logConnectionEvents (conn) {
  // Emitted after getting disconnected from the db.
  // _readyState: 0
  conn.on('disconnected', () => {
    conn.$logger.debug('Disconnected!')
  })

  // Emitted when this connection successfully connects to the db.
  // May be emitted multiple times in reconnected scenarios.
  // _readyState: 1
  conn.on('connected', () => {
    conn.$logger.success('Connected!')
  })

  // Emitted when connection.{open,openSet}() is executed on this connection.
  // _readyState: 2
  conn.on('connecting', () => {
    conn.$logger.info('Connecting...')
  })

  // Emitted when connection.close() was executed.
  // _readyState: 3
  conn.on('disconnecting', () => {
    conn.$logger.debug('Disconnecting...')
  })

  // Emitted when an error occurs on this connection.
  conn.on('error', (error) => {
    conn.$logger.error(error)
  })

  // Emitted after we connected and onOpen is executed
  // on all of this connections models.
  conn.on('open', () => {
    conn.$logger.debug('Connection opened!')
  })

  // Emitted after we connected and subsequently disconnected,
  // followed by successfully another successfull connection.
  conn.on('reconnected', () => {
    conn.$logger.debug('Reconnected!')
  })

  // Emitted in a replica-set scenario, when all nodes specified
  // in the connection string are connected.
  conn.on('fullsetup', () => {
    conn.$logger.debug('ReplicaSet ready!')
  })
}
552035
protected void releaseConnection(Object conn)
    {
        clientFactory.releaseConnection(((Connection) conn).getPool(), ((Connection) conn).getClient());
    }
734384
private function parseConn($conn)
    {
        while(true)
        {
            $meta = fread($conn, 4);
            if('' === $meta || false === $meta)
            {
                return;
            }
            $length = unpack('N', $meta)[1];
            $data = fread($conn, $length);
            if(false === $data || !isset($data[$length - 1]))
            {
                return;
            }
            $body = ($this->unserialize)($data);
            if(!$body instanceof Operation)
            {
                return;
            }
            try{
                $result = new Result($this->operationParser->parse($body));
            } catch(\Throwable $th) {
                $result = new Result(null, $th);
            }
            $resultData = ($this->serialize)($result);
            $length = strlen($resultData);
            $resultData = pack('N', $length) . $resultData;
            fwrite($conn, $resultData, $length + 4);
        }
    }
509271
void releaseConnection(ConnectionPool pool, Cassandra.Client conn)
    {
        if (pool != null && conn != null)
        {
            pool.release(conn);
        }
    }
1322036
private function maybeUpdateRDY(Connection $conn)
    {
        if ($this->inBackoff() || $this->inBackoffTimeout()) {
            return;
        }

        $remainRDY = $conn->getRemainRDY();
        $lastRdyCount = $conn->lastRDY();
        $perConnMax = $this->perConnMaxInFlight();

        if ($remainRDY <= 1 || $remainRDY < ($lastRdyCount / 4) || ($perConnMax > 0 && $perConnMax < $remainRDY)) {
            $this->updateRDY($conn, $perConnMax);
        }
    }
104366
public void addConnection(WebSocketConnection conn) {
        conns.add(conn);
        for (IWebSocketDataListener listener : listeners) {
            listener.onWSConnect(conn);
        }
    }
528580
async def release(self, conn):
        
        assert conn in self._used, (conn, self._used)
        self._used.remove(conn)
        if not conn.closed:
            if self._closing:
                await conn.close()
            else:
                self._free.append(conn)
            await self._wakeup()
137658
private void flushURLConnection(URLConnection conn) {
        byte[] buf = new byte[1024];
        try {
            InputStream is = conn.getInputStream();
            while (is.read(buf) >= 0) {
                // Ignore
            }
            is.close();
        } catch (IOException e) {
            try {
                InputStream es = ((HttpURLConnection) conn).getErrorStream();
                if (es != null) {
                    while (es.read(buf) >= 0) {
                        // Ignore
                    }
                    es.close();
                }
            } catch (IOException ex) {
                // Ignore
            }
        }
    }
874764
public function connect($url, $cb, $class = null)
    {
        if ($class === null) {
            $class = $this->connectionClass;
        }
        $conn = new $class(null, $this);
        $conn->connect($url, $cb);
        return $conn;
    }