pocketmine\utils\Binary::readLInt PHP Méthode

readLInt() public static méthode

public static readLInt ( $str )
    public static function readLInt($str)
    {
        if (PHP_INT_SIZE === 8) {
            return unpack("V", $str)[1] << 32 >> 32;
        } else {
            return unpack("V", $str)[1];
        }
    }

Usage Example

 private function readPacket($client, &$size, &$requestID, &$packetType, &$payload)
 {
     socket_set_nonblock($client);
     $d = socket_read($client, 4);
     if ($this->stop === true) {
         return false;
     } elseif ($d === false) {
         return null;
     } elseif ($d === "" or strlen($d) < 4) {
         return false;
     }
     socket_set_block($client);
     $size = Binary::readLInt($d);
     if ($size < 0 or $size > 65535) {
         return false;
     }
     $requestID = Binary::readLInt(socket_read($client, 4));
     $packetType = Binary::readLInt(socket_read($client, 4));
     $payload = rtrim(socket_read($client, $size + 2));
     //Strip two null bytes
     return true;
 }
All Usage Examples Of pocketmine\utils\Binary::readLInt