public function command() {
    try {
      $args = func_get_args();
      $commandName = $args[0];
      array_shift($args);
      $messageToSend = json_encode(array('name' => $commandName, 'args' => $args));
      /** @var $commandResponse \GuzzleHttp\Psr7\Response|\GuzzleHttp\Message\Response */
      $commandResponse = $this->getApiClient()->post("/api", array("body" => $messageToSend));
      $jsonResponse = json_decode($commandResponse->getBody(), TRUE);
    } catch (ServerException $e) {
      $jsonResponse = json_decode($e->getResponse()->getBody()->getContents(), true);
    } catch (ConnectException $e) {
      throw new DeadClient($e->getMessage(), $e->getCode(), $e);
    } catch (\Exception $e) {
      throw $e;
    }

    if (isset($jsonResponse['error'])) {
      throw $this->getErrorClass($jsonResponse);
    }

    return $jsonResponse['response'];
  }
public function command() {
    try {
      $args = func_get_args();
      $commandName = $args[0];
      array_shift($args);
      $messageToSend = json_encode(array('name' => $commandName, 'args' => $args));
      /** @var $commandResponse \GuzzleHttp\Psr7\Response|\GuzzleHttp\Message\Response */
      $commandResponse = $this->getApiClient()->post("/api", array("body" => $messageToSend));
      $jsonResponse = json_decode($commandResponse->getBody(), TRUE);
    } catch (ServerException $e) {
      $jsonResponse = json_decode($e->getResponse()->getBody()->getContents(), true);
    } catch (ConnectException $e) {
      throw new DeadClient($e->getMessage(), $e->getCode(), $e);
    } catch (\Exception $e) {
      throw $e;
    }

    if (isset($jsonResponse['error'])) {
      throw $this->getErrorClass($jsonResponse);
    }

    return $jsonResponse['response'];
  }
public function command ( ) { try { $ args = func_get_args ( ) ; $ commandName = $ args [ 0 ] ; array_shift ( $ args ) ; $ messageToSend = json_encode ( array ( 'name' => $ commandName , 'args' => $ args ) ) ; /** @var $commandResponse \GuzzleHttp\Psr7\Response|\GuzzleHttp\Message\Response */ $ commandResponse = $ this -> getApiClient ( ) -> post ( "/api" , array ( "body" => $ messageToSend ) ) ; $ jsonResponse = json_decode ( $ commandResponse -> getBody ( ) , TRUE ) ; } catch ( ServerException $ e ) { $ jsonResponse = json_decode ( $ e -> getResponse ( ) -> getBody ( ) -> getContents ( ) , true ) ; } catch ( ConnectException $ e ) { throw new DeadClient ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } catch ( \ Exception $ e ) { throw $ e ; } if ( isset ( $ jsonResponse [ 'error' ] ) ) { throw $ this -> getErrorClass ( $ jsonResponse ) ; } return $ jsonResponse [ 'response' ] ; }
Sends a command to the browser
@throws BrowserError
@throws \Exception
@return mixed
Sends a command to the browser