Initializes an added connection.

@param string $remote
@param \Phergie\Irc\ConnectionInterface $connection
964125
protected function initializeConnection($remote, $connection)
    {
        try {
            $context = $this->getContext($connection);
            $socket = $this->getSocket($remote, $context);
            $stream = $this->getStream($socket);
            $this->initializeStream($stream, $connection);
            $this->addActiveConnection($connection);
        } catch (\Exception $e) {
            $this->emitConnectionError($e, $connection);
        }

        $this->emit('connect.after.each', array($connection, $connection->getData('write')));
    }
640202
public function setConnection(Connection $connection)
    {
        if (! in_array($connection, $this->_connections, true)) {
            $this->_connections[] = $connection;
        }
    }
1325656
public function onSocketConnect($socket, Connection $connection): void
    {
        $this->checkConnections($connection);
        $this->checkConnectionsPerIp($connection);
    }
683159
public function execute(ConnectionInterface $connection, array $argv)
    {

        // initialize input/output instances
        $input = new ArgvInput($argv);
        $output = new BufferedOutput();

        // initialize the execution context
        $executionContext = new ExecutionContext();
        $executionContext->injectInput($input);
        $executionContext->injectOutput($output);
        $executionContext->injectApplication($this->getApplication());

        // start the execution context
        $executionContext->start();
        $executionContext->join();

        // write the result back to the connection
        $executionContext->write($connection);
    }
1159513
protected function writeToRemote($data, $connection)
    {
        $buffer = serialize($data);
        $buffer = pack('N', 4 + strlen($buffer)) . $buffer;
        $len = fwrite($connection, $buffer);
        if ($len !== strlen($buffer)) {
            throw new \Exception('writeToRemote fail');
        }
    }
680306
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        $params = $connection->getParams();
        if (!isset($params['charset'])) {
            throw new RuntimeException("No connection charset specified");
        }
        $pdo->exec('SET NAMES ' . $pdo->quote($params['charset']));
    }
1067220
public function onCreateConnection(HostEvent $event)
    {
        $connectionAdapter = $this->getConnectionAdapter($event->getHost());
        if ($connectionAdapter instanceof ConnectionAdapterInterface) {
            $event->getHost()->setConnection($connectionAdapter);
        }
    }
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);
	}
481858
public function register($pid, ConnectionInterface $connection)
    {
        if ($this->status !== self::CREATED) {
            throw new \LogicException('Cannot register a slave that is not in created state');
        }

        $this->pid = $pid;
        $this->connection = $connection;

        $this->status = self::REGISTERED;
    }
365407
protected function createRedirectUrisTable(Connection $connection, DatabaseSchemaInterface $schema): void
    {
        $manager = $connection->getSchemaManager();

        $table = new Table($schema->getRedirectUrisTable());
        $table->addColumn($schema->getRedirectUrisIdentityColumn(), Type::INTEGER)
            ->setNotnull(true)->setAutoincrement(true)->setUnsigned(true);
        $table->addColumn($schema->getRedirectUrisClientIdentityColumn(), Type::STRING)->setNotnull(true);
        $table->addColumn($schema->getRedirectUrisValueColumn(), Type::STRING)->setNotnull(true);
        $table->addColumn($schema->getRedirectUrisCreatedAtColumn(), Type::DATETIME)->setNotnull(true);
        $table->addColumn($schema->getRedirectUrisUpdatedAtColumn(), Type::DATETIME)->setNotnull(false);
        $table->setPrimaryKey([$schema->getRedirectUrisIdentityColumn()]);

        $table->addForeignKeyConstraint(
            $schema->getClientsTable(),
            [$schema->getRedirectUrisClientIdentityColumn()],
            [$schema->getClientsIdentityColumn()],
            $this->getOnDeleteCascadeConstraint()
        );

        $manager->dropAndCreateTable($table);
    }
738159
protected function subscribe(ConnectionInterface $connection, stdClass $payload)
    {
        $channel = $this->channelManager->findOrCreate($connection->app->id, $payload->channel);

        $channel->subscribe($connection, $payload);
    }
1051482
public function add(Connection $connection)
    {
        $key = md5(serialize($connection->getParams()));
        if (isset($this->connections[$key]) && $connection !== $this->connections[$key]) {
            throw new \InvalidArgumentException('Expects a non registered connection.');
        }
        $this->connections[$key] = $connection;
    }
400081
public function initConnection(ConnectionInterface $con, array $settings)
    {
        $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        $con->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, false);

        parent::initConnection($con, $settings);
    }
1013551
public function setConnection($connection)
	{
		if (is_string($connection)) {
			$connection = Yii::$app->{$connection};
		}
		$this->_connection = $connection;
	}
847365
public function setData($connectName, $driver,Connection $connection)
    {
        $this->connectName = $connectName;
        $this->driver = $driver;
        $this->connection = $connection;
        return $this;
    }
425222
protected function addLogging(EventEmitter $emitter, ConnectionInterface $connection)
    {
        $emitter->on('data', $this->getOutputLogCallback($connection, 'debug'));
        $emitter->on('error', $this->getOutputLogCallback($connection, 'notice'));
    }
839406
public void init(Rec record, RemoteTable tableRemote, Object syncObject)
    {
        super.init(record);
        this.setRemoteTable(tableRemote, syncObject);
    }