Attach listener to connection.

@param  \Denpa\ZeroMQ\Connection  $connection

@return self
972507
public function listenOn(ZMQConnection $connection) : self
    {
        $connection->subscribe([$this->topic], function ($message) {
            return $this->onSuccess($message);
        });

        return $this;
    }
588124
public function onGatewayClose($connection)
    {
        $addr = $connection->remoteAddress;
        unset($this->gatewayConnections[$addr], $this->_connectingGatewayAddresses[$addr]);
        if (isset($this->_gatewayAddresses[$addr]) && !isset($this->_waitingConnectGatewayAddresses[$addr])) {
            Timer::add(1, array($this, 'tryToConnectGateway'), array($addr), false);
            $this->_waitingConnectGatewayAddresses[$addr] = $addr;
        }
    }
323885
public function commit(ConnectionInterface $connection)
    {
        // We decrement the transaction level and prevent events to be dispatched
        // while comitting nested transactions, so no transient state is saved.
        // Only dispatch events right after the outer transaction commits.
        $this->transactionLevel--;
        if (! $this->isPrepared($connection) || $this->transactionLevel > 0) {
            return;
        }

        $this->dispatchPendingEvents($connection);
    }
485119
public function onConnection(ConnectionInterface $connection)
    {
        $this->log('New connection from ' . $connection->getRemoteAddress());

        $buffer = '';
        $connection->on('data', function ($data) use (&$buffer, &$connection) {
            $buffer .= $data;

            if (strpos($buffer, Client::END_OF_COMMAND)) {
                $chunks = explode(Client::END_OF_COMMAND, $buffer);
                $count = count($chunks);
                $buffer = $chunks[$count - 1];

                for ($i = 0; $i < $count - 1; $i++) {
                    $command = json_decode($chunks[$i], true);
                    $this->runCommand($command, $connection);
                }
            }
        });
    }
463706
public function rollback(ConnectionInterface $connection)
    {
        $connectionId = $connection->getName();

        if ($this->transactionLevel > 1) {
            array_pop($this->pendingEvents[$connectionId][$this->transactionLevel]);
        } else {
            unset($this->pendingEvents[$connectionId]);
        }

        $this->transactionLevel--;
    }
847365
public function setData($connectName, $driver,Connection $connection)
    {
        $this->connectName = $connectName;
        $this->driver = $driver;
        $this->connection = $connection;
        return $this;
    }
1013551
public function setConnection($connection)
	{
		if (is_string($connection)) {
			$connection = Yii::$app->{$connection};
		}
		$this->_connection = $connection;
	}
189972
protected function configure(Connection $connection, $type)
	{
		$connection = $this->setPdoForType($connection, $type);

		// First we'll set the fetch mode and a few other dependencies of the database
		// connection. This method basically just configures and prepares it to get
		// used by the application. Once we're finished we'll return it back out.
		if ($this->prop->getIs('events'))
		{
			$connection->setEventDispatcher($this->prop['events']);
		}

		// Here we'll set a reconnector callback. This reconnector can be any callable
		// so we will set a Closure to reconnect from this manager with the name of
		// the connection, which will allow us to reconnect from the connections.
		$connection->setReconnector(function ($connection) {
			$this->reconnect($connection->getName());
		});

		return $connection;
	}
404330
protected static function build( $connection ) {
		$connections = static::connections();

		if ( empty( $connections[ $connection ] ) ) {
			throw new ConnectionNotFoundException();
		}

		static::$instances[ $connection ] = new Queue( $connections[ $connection ] );

		return static::$instances[ $connection ];
	}
640202
public function setConnection(Connection $connection)
    {
        if (! in_array($connection, $this->_connections, true)) {
            $this->_connections[] = $connection;
        }
    }
268582
private function releaseToQueue(ConnectionInterface $connection)
    {
        if ($this->queue->count() < $this->poolConfig->getMaxActive()) {
            $this->queue->push($connection);
            if ($this->poolConfig->getWaitStack()->count() > 0) {
                $id = $this->poolConfig->getWaitStack()->shift();
                \Swoole\Coroutine::resume($id);
            }
        }
    }
337932
public function addConnection(\Nofuzz\Database\PdoConnectionInterface $connection)
  {
    $this->connections[strtolower($connection->getName())] = $connection;

    return $connection;
  }
475651
protected function checkConnections($connection)
    {
        $connections = $connection->getConnectionManager()->count();

        if ($connections > $this->options['connections']) {
            $this->limit($connection, 'Max connections');
        }
    }
171218
protected function addUnsecuredConnection(ConnectionInterface $connection)
    {
        $this->getRemote($connection)->then(
            function($remote) use($connection) {
                $this->initializeConnection($remote, $connection);
            },
            function($error) use($connection) {
                $this->emitConnectionError($error, $connection);
            }
        );
    }
102987
protected function connect(string $connection): Redis
	{
		if(!isset($this->configurations[$connection]))
		{
			throw new RuntimeException(vsprintf('[ %s ] has not been defined in the redis configuration.', [$connection]));
		}

		$config = $this->configurations[$connection];

		return new Redis(new Connection($config['host'], $config['port'], $config['persistent'] ?? false, $config['timeout'] ?? 60, $connection), $config);
	}
1302758
protected function setOutput(Connection $connection)
	{
		$output = php_sapi_name() == 'cli' ? new ConsoleOutput : new NullOutput;

		$connection->setOutput($output);
	}
764430
public function connection(ConnectionInterface $connection = null)
    {
        deprecationWarning(
            get_called_class() . '::connection() is deprecated. ' .
            'Use setConnection()/getConnection() instead.'
        );
        if ($connection !== null) {
            $this->setConnection($connection);
        }

        return $this->getConnection();
    }