protected function handleCommand(string $clientAddress, string $command) : bool
    {
        switch ($command) {
            case 'stop':
                $this->respondToClient($clientAddress, 'ok');
                $this->stop();
                return true;
            case 'status':
                $statusData = $this->getStatusData();
                $this->respondToClient($clientAddress, json_encode($statusData));
                return true;
            case 'flush_queue':
                $result = ($this->flushQueue() === true) ? 'ok' : 'error';
                $this->respondToClient($clientAddress, $result);
                return true;

        }
        $this->respondToClient($clientAddress, 'error');
        throw new ServerException('Received unknown command.');
    }
protected function handleCommand(string $clientAddress, string $command) : bool
    {
        switch ($command) {
            case 'stop':
                $this->respondToClient($clientAddress, 'ok');
                $this->stop();
                return true;
            case 'status':
                $statusData = $this->getStatusData();
                $this->respondToClient($clientAddress, json_encode($statusData));
                return true;
            case 'flush_queue':
                $result = ($this->flushQueue() === true) ? 'ok' : 'error';
                $this->respondToClient($clientAddress, $result);
                return true;

        }
        $this->respondToClient($clientAddress, 'error');
        throw new ServerException('Received unknown command.');
    }
protected function handleCommand ( string $ clientAddress , string $ command ) : bool { switch ( $ command ) { case 'stop' : $ this -> respondToClient ( $ clientAddress , 'ok' ) ; $ this -> stop ( ) ; return true ; case 'status' : $ statusData = $ this -> getStatusData ( ) ; $ this -> respondToClient ( $ clientAddress , json_encode ( $ statusData ) ) ; return true ; case 'flush_queue' : $ result = ( $ this -> flushQueue ( ) === true ) ? 'ok' : 'error' ; $ this -> respondToClient ( $ clientAddress , $ result ) ; return true ; } $ this -> respondToClient ( $ clientAddress , 'error' ) ; throw new ServerException ( 'Received unknown command.' ) ; }
Executes commands received from a client.

@param string $clientAddress
@param string $command
@throws ServerException
@return bool
Executes commands received from a client .