original_string: private function registerClient(Connection $connection, $timeout)
      {
          $deferred = new Deferred();
  
          $responseTimer = $this->loop->addTimer(
              $timeout,
              function () use ($deferred, $timeout) {
                  $exception = new \RuntimeException(sprintf('No response after %d seconds.', $timeout));
                  $deferred->reject($exception);
              }
          );
  
          $this->startFlow(new OutgoingConnectFlow($connection, $this->identifierGenerator), true)
              ->always(function () use ($responseTimer) {
                  $this->loop->cancelTimer($responseTimer);
              })->then(function (Connection $connection) use ($deferred) {
                  $this->timer[] = $this->loop->addPeriodicTimer(
                      floor($connection->getKeepAlive() * 0.75),
                      function () {
                          $this->startFlow(new OutgoingPingFlow());
                      }
                  );
  
                  $deferred->resolve($connection);
              })->otherwise(function (\Exception $e) use ($deferred) {
                  $deferred->reject($e);
              });
  
          return $deferred->promise();
      }
code: private function registerClient(Connection $connection, $timeout)
      {
          $deferred = new Deferred();
  
          $responseTimer = $this->loop->addTimer(
              $timeout,
              function () use ($deferred, $timeout) {
                  $exception = new \RuntimeException(sprintf('No response after %d seconds.', $timeout));
                  $deferred->reject($exception);
              }
          );
  
          $this->startFlow(new OutgoingConnectFlow($connection, $this->identifierGenerator), true)
              ->always(function () use ($responseTimer) {
                  $this->loop->cancelTimer($responseTimer);
              })->then(function (Connection $connection) use ($deferred) {
                  $this->timer[] = $this->loop->addPeriodicTimer(
                      floor($connection->getKeepAlive() * 0.75),
                      function () {
                          $this->startFlow(new OutgoingPingFlow());
                      }
                  );
  
                  $deferred->resolve($connection);
              })->otherwise(function (\Exception $e) use ($deferred) {
                  $deferred->reject($e);
              });
  
          return $deferred->promise();
      }
code_tokens: private function registerClient ( Connection $ connection , $ timeout ) { $ deferred = new Deferred ( ) ; $ responseTimer = $ this -> loop -> addTimer ( $ timeout , function ( ) use ( $ deferred , $ timeout ) { $ exception = new \ RuntimeException ( sprintf ( 'No response after %d seconds.' , $ timeout ) ) ; $ deferred -> reject ( $ exception ) ; } ) ; $ this -> startFlow ( new OutgoingConnectFlow ( $ connection , $ this -> identifierGenerator ) , true ) -> always ( function ( ) use ( $ responseTimer ) { $ this -> loop -> cancelTimer ( $ responseTimer ) ; } ) -> then ( function ( Connection $ connection ) use ( $ deferred ) { $ this -> timer [ ] = $ this -> loop -> addPeriodicTimer ( floor ( $ connection -> getKeepAlive ( ) * 0.75 ) , function ( ) { $ this -> startFlow ( new OutgoingPingFlow ( ) ) ; } ) ; $ deferred -> resolve ( $ connection ) ; } ) -> otherwise ( function ( \ Exception $ e ) use ( $ deferred ) { $ deferred -> reject ( $ e ) ; } ) ; return $ deferred -> promise ( ) ; }
docstring: Registers a new client with the broker.
  
  @param Connection $connection
  @param int        $timeout
  
  @return ExtendedPromiseInterface
docstring_tokens: Registers a new client with the broker .