15declare(strict_types=1);
17namespace raklib\protocol;
23use
const SORT_NUMERIC;
26 private const RECORD_TYPE_RANGE = 0;
27 private const RECORD_TYPE_SINGLE = 1;
30 public array $packets = [];
34 sort($this->packets, SORT_NUMERIC);
35 $count = count($this->packets);
40 $start = $this->packets[0];
41 $last = $this->packets[0];
43 while($pointer < $count){
44 $current = $this->packets[$pointer++];
45 $diff = $current - $last;
50 $payload .= chr(self::RECORD_TYPE_SINGLE);
52 $start = $last = $current;
54 $payload .= chr(self::RECORD_TYPE_RANGE);
57 $start = $last = $current;
64 $payload .= chr(self::RECORD_TYPE_SINGLE);
67 $payload .= chr(self::RECORD_TYPE_RANGE);
74 $out->putShort($records);
79 $count = $in->getShort();
82 for($i = 0; $i < $count and !$in->
feof() and $cnt < 4096; ++$i){
83 if($in->
getByte() === self::RECORD_TYPE_RANGE){
86 if(($end - $start) > 512){
89 for($c = $start; $c <= $end; ++$c){
90 $this->packets[$cnt++] = $c;
93 $this->packets[$cnt++] = $in->
getLTriad();
static writeLTriad(int $value)
decodePayload(PacketSerializer $in)