/**
  * Get challenge (used for players/rules packets)
  *
  * @return bool True if all went well, false if server uses old GoldSource protocol, and it already contains answer
  */
 private function GetChallenge($Header, $ExpectedResult)
 {
     if ($this->Challenge) {
         return self::GETCHALLENGE_ALL_CLEAR;
     }
     $this->Socket->Write($Header, 0xffffffff);
     $this->Socket->Read();
     $Type = $this->Buffer->GetByte();
     switch ($Type) {
         case self::S2A_CHALLENGE:
             $this->Challenge = $this->Buffer->Get(4);
             return self::GETCHALLENGE_ALL_CLEAR;
         case $ExpectedResult:
             // Goldsource (HLTV)
             return self::GETCHALLENGE_CONTAINS_ANSWER;
         case 0:
             return self::GETCHALLENGE_FAILED;
         default:
             throw new SourceQueryException('GetChallenge: Packet header mismatch. (0x' . DecHex($Type) . ')');
     }
 }
 /**
  * Get challenge (used for players/rules packets)
  *
  * @param $Header
  * @param $ExpectedResult
  * @throws InvalidPacketException
  * @return bool True if all went well, false if server uses old GoldSource protocol, and it already contains answer
  */
 private function GetChallenge($Header, $ExpectedResult)
 {
     if ($this->Challenge) {
         return self::GETCHALLENGE_ALL_CLEAR;
     }
     if ($this->UseOldGetChallengeMethod) {
         $Header = self::A2S_SERVERQUERY_GETCHALLENGE;
     }
     $this->Socket->Write($Header, 0xffffffff);
     $this->Socket->Read();
     $Type = $this->Buffer->GetByte();
     switch ($Type) {
         case self::S2A_CHALLENGE:
             $this->Challenge = $this->Buffer->Get(4);
             return self::GETCHALLENGE_ALL_CLEAR;
         case $ExpectedResult:
             // Goldsource (HLTV)
             return self::GETCHALLENGE_CONTAINS_ANSWER;
         case 0:
             return self::GETCHALLENGE_FAILED;
         default:
             throw new InvalidPacketException('GetChallenge: Packet header mismatch. (0x' . DecHex($Type) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH);
     }
 }