protected function handleResponseForRequest($requestType, $repeatOnFailure = true) {
        switch($requestType) {
            case self::REQUEST_CHALLENGE:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2CCHALLENGEPacket';
                $requestPacket    = new A2SPLAYERPacket();
                break;
            case self::REQUEST_INFO:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2AINFOBasePacket';
                $requestPacket    = new A2SINFOPacket();
                break;
            case self::REQUEST_PLAYER:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2APLAYERPacket';
                $requestPacket    = new A2SPLAYERPacket($this->challengeNumber);
                break;
            case self::REQUEST_RULES:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2ARULESPacket';
                $requestPacket    = new A2SRULESPacket($this->challengeNumber);
                break;
            default:
                throw new SteamCondenserException('Called with wrong request type.');
        }

        $this->socket->send($requestPacket);
        $responsePacket = $this->socket->getReply();

        if($responsePacket instanceof S2AINFOBasePacket) {
            $this->infoHash = $responsePacket->getInfo();
        } elseif($responsePacket instanceof S2APLAYERPacket) {
            $this->playerHash = $responsePacket->getPlayerHash();
        } elseif($responsePacket instanceof S2ARULESPacket) {
            $this->rulesHash = $responsePacket->getRulesArray();
        } elseif($responsePacket instanceof S2CCHALLENGEPacket) {
            $this->challengeNumber = $responsePacket->getChallengeNumber();
        } else {
            throw new SteamCondenserException('Response of type ' . get_class($responsePacket) . ' cannot be handled by this method.');
        }

        if(!($responsePacket instanceof $expectedResponse)) {
            $this->logger->info("Expected {$expectedResponse}, got " . get_class($responsePacket) . '.');
            if($repeatOnFailure) {
                $this->handleResponseForRequest($requestType, false);
            }
        }
    }
protected function handleResponseForRequest($requestType, $repeatOnFailure = true) {
        switch($requestType) {
            case self::REQUEST_CHALLENGE:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2CCHALLENGEPacket';
                $requestPacket    = new A2SPLAYERPacket();
                break;
            case self::REQUEST_INFO:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2AINFOBasePacket';
                $requestPacket    = new A2SINFOPacket();
                break;
            case self::REQUEST_PLAYER:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2APLAYERPacket';
                $requestPacket    = new A2SPLAYERPacket($this->challengeNumber);
                break;
            case self::REQUEST_RULES:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2ARULESPacket';
                $requestPacket    = new A2SRULESPacket($this->challengeNumber);
                break;
            default:
                throw new SteamCondenserException('Called with wrong request type.');
        }

        $this->socket->send($requestPacket);
        $responsePacket = $this->socket->getReply();

        if($responsePacket instanceof S2AINFOBasePacket) {
            $this->infoHash = $responsePacket->getInfo();
        } elseif($responsePacket instanceof S2APLAYERPacket) {
            $this->playerHash = $responsePacket->getPlayerHash();
        } elseif($responsePacket instanceof S2ARULESPacket) {
            $this->rulesHash = $responsePacket->getRulesArray();
        } elseif($responsePacket instanceof S2CCHALLENGEPacket) {
            $this->challengeNumber = $responsePacket->getChallengeNumber();
        } else {
            throw new SteamCondenserException('Response of type ' . get_class($responsePacket) . ' cannot be handled by this method.');
        }

        if(!($responsePacket instanceof $expectedResponse)) {
            $this->logger->info("Expected {$expectedResponse}, got " . get_class($responsePacket) . '.');
            if($repeatOnFailure) {
                $this->handleResponseForRequest($requestType, false);
            }
        }
    }
protected function handleResponseForRequest ( $ requestType , $ repeatOnFailure = true ) { switch ( $ requestType ) { case self :: REQUEST_CHALLENGE : $ expectedResponse = '\SteamCondenser\Servers\Packets\S2CCHALLENGEPacket' ; $ requestPacket = new A2SPLAYERPacket ( ) ; break ; case self :: REQUEST_INFO : $ expectedResponse = '\SteamCondenser\Servers\Packets\S2AINFOBasePacket' ; $ requestPacket = new A2SINFOPacket ( ) ; break ; case self :: REQUEST_PLAYER : $ expectedResponse = '\SteamCondenser\Servers\Packets\S2APLAYERPacket' ; $ requestPacket = new A2SPLAYERPacket ( $ this -> challengeNumber ) ; break ; case self :: REQUEST_RULES : $ expectedResponse = '\SteamCondenser\Servers\Packets\S2ARULESPacket' ; $ requestPacket = new A2SRULESPacket ( $ this -> challengeNumber ) ; break ; default : throw new SteamCondenserException ( 'Called with wrong request type.' ) ; } $ this -> socket -> send ( $ requestPacket ) ; $ responsePacket = $ this -> socket -> getReply ( ) ; if ( $ responsePacket instanceof S2AINFOBasePacket ) { $ this -> infoHash = $ responsePacket -> getInfo ( ) ; } elseif ( $ responsePacket instanceof S2APLAYERPacket ) { $ this -> playerHash = $ responsePacket -> getPlayerHash ( ) ; } elseif ( $ responsePacket instanceof S2ARULESPacket ) { $ this -> rulesHash = $ responsePacket -> getRulesArray ( ) ; } elseif ( $ responsePacket instanceof S2CCHALLENGEPacket ) { $ this -> challengeNumber = $ responsePacket -> getChallengeNumber ( ) ; } else { throw new SteamCondenserException ( 'Response of type ' . get_class ( $ responsePacket ) . ' cannot be handled by this method.' ) ; } if ( ! ( $ responsePacket instanceof $ expectedResponse ) ) { $ this -> logger -> info ( "Expected {$expectedResponse}, got " . get_class ( $ responsePacket ) . '.' ) ; if ( $ repeatOnFailure ) { $ this -> handleResponseForRequest ( $ requestType , false ) ; } } }
Sends the specified request to the server and handles the returned
response

Depending on the given request type this will fill the various data
attributes of the server object.

@param int $requestType The type of request to send to the server
@param bool $repeatOnFailure Whether the request should be repeated, if
the replied packet isn't expected. This is useful to handle
missing challenge numbers, which will be automatically filled in,
although not requested explicitly.
@throws SteamCondenserException if either the request type or the
response packet is not known
Sends the specified request to the server and handles the returned response