Register a slave after it's process started

@param int $pid
@param ConnectionInterface $connection

@return void
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;
    }
1096109
public function getEventQueue(ConnectionInterface $connection)
    {
        if (!isset($this->queues[$connection])) {
            $this->queues[$connection] = new EventQueue;
        }
        return $this->queues[$connection];
    }
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);
            }
        );
    }
293821
protected function addPendingEvent($connection, $event, $payload)
    {
        $connectionId = $connection->getName();
        $transactionLevel = $this->transactionLevel;

        $eventData = [
            'event' => $event,
            'payload' => is_object($payload) ? clone $payload : $payload,
        ];
        $transactionLevelEvents = &$this->pendingEvents[$connectionId][$transactionLevel];
        $transactionLevelEvents[count($transactionLevelEvents) - 1][] = $eventData;
    }
556769
public function addConnection(string $name = null, Connection $connection = null): self
    {
        if (is_null($name)) {
            $this->defaultConnection = $connection;
        } else {
            $this->registry[$name] = $connection;
        }

        return $this;
    }
193893
public function onClose(ConnectionInterface $connection)
    {
        $client = $this->clients->findByConnection($connection);

        if ($client) {
            $this->clients->remove($client);

            $this->command->info('Client disconnected');

            // Fire the event.
            Event::fire(new ClientDisconnected($this->server, $this->clients, $client));
        }
    }
880768
ServerSessionManager registerConnection(String client, Connection connection) {
    ServerSessionContext session = clients.get(client);
    if (session != null) {
      session.setConnection(connection);
    }
    connections.put(client, connection);
    return this;
  }
554355
public function onOpen(ConnectionInterface $conn) {

        // store the new connection
        $this->clients->attach($conn);

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

        // start profiler
        if(defined('SONAR_VERBOSE') === true) {
            Profiler::start();
        }
    }
600361
protected function dispatchPendingEvents(ConnectionInterface $connection)
    {
        $connectionId = $connection->getName();
        $consumingEvents = $this->pendingEvents[$connectionId];

        unset($this->pendingEvents[$connectionId]);

        foreach ($consumingEvents as $transactionsEvents) {
            foreach ($transactionsEvents as $transactionEvents) {
                foreach ($transactionEvents as $event) {
                    $this->dispatcher->dispatch($event['event'], $event['payload']);
                }
            }
        }
    }
548189
protected function prepareConnection(NodeConnectionInterface $connection)
    {
        $parameters = $connection->getParameters();

        if (isset($parameters->password)) {
            $connection->addConnectCommand(
                new RawCommand(array('AUTH', $parameters->password))
            );
        }

        if (isset($parameters->database)) {
            $connection->addConnectCommand(
                new RawCommand(array('SELECT', $parameters->database))
            );
        }
    }
733217
public function handle(ConnectionInterface $incoming)
    {
        $this->incoming = $incoming;

        $this->incoming->on('data', [$this, 'handleData']);
        $this->incoming->on('close', function () {
            $this->connectionOpen = false;
        });

        $this->start = microtime(true);
        $this->requestSentAt = microtime(true);
        $this->getNextSlave();

        if ($this->maxExecutionTime > 0) {
            $this->maxExecutionTimer = $this->loop->addTimer($this->maxExecutionTime, [$this, 'maxExecutionTimeExceeded']);
        }
    }
1117749
public void registerConnection(Connection connection, ConnectionDefinition connectionDefinition) {
        checkNotNull(connection);
        checkNotNull(connectionDefinition);

        if (this.connectionDefinitions.putIfAbsent(connectionDefinition.getName(), connectionDefinition) != null) {
            throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
        }

        if (this.connections.putIfAbsent(connectionDefinition.getName(), connection) != null) {
            throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
        }

        if (shouldStartConnections.get()) {
            try {
                connection.start();
            } catch (JMSException e) {
                throw SeedException.wrap(e, JmsErrorCode.UNABLE_TO_START_JMS_CONNECTION).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
            }
        }
    }
929081
protected function initializeStream(DuplexStreamInterface $stream, ConnectionInterface $connection)
    {
        try {
            $connection->setData('stream', $stream);
            $write = $this->getWriteStream($connection);
            $connection->setData('write', $write);
            $this->configureStreams($connection, $stream, $write);
            $this->identifyUser($connection, $write);
        } catch (\Exception $e) {
            $this->emitConnectionError($e, $connection);
        }
    }
159825
public function postInsert(ConnectionInterface $con = null)
    {
        parent::postInsert($con);

        $this->dispatchEvent(TheliaEvents::AFTER_CREATEADDRESS, new AddressEvent($this));
    }
420131
private function releaseToQueue(ConnectionInterface $connection)
    {
        if ($this->queue->count() < $this->poolConfig->getMaxActive()) {
            $this->queue->push($connection);
        }
    }
613950
protected function discoverFromMaster(NodeConnectionInterface $connection, FactoryInterface $connectionFactory)
    {
        $response = $connection->executeCommand(RawCommand::create('INFO', 'REPLICATION'));
        $replication = $this->handleInfoResponse($response);

        if ($replication['role'] !== 'master') {
            throw new ClientException("Role mismatch (expected master, got slave) [$connection]");
        }

        $this->slaves = array();

        foreach ($replication as $k => $v) {
            $parameters = null;

            if (strpos($k, 'slave') === 0 && preg_match('/ip=(?P<host>.*),port=(?P<port>\d+)/', $v, $parameters)) {
                $slaveConnection = $connectionFactory->create(array(
                    'host' => $parameters['host'],
                    'port' => $parameters['port'],
                ));

                $this->add($slaveConnection);
            }
        }
    }
1080119
protected function addActiveConnection(ConnectionInterface $connection)
    {
        if (!$this->activeConnections) {
            $this->activeConnections = new \SplObjectStorage;
        }
        $this->activeConnections->attach($connection);
    }