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);
 
   51                        $payload .= Binary::writeLTriad($start);
 
   52                        $start = $last = $current;
 
   54                        $payload .= chr(self::RECORD_TYPE_RANGE);
 
   55                        $payload .= Binary::writeLTriad($start);
 
   56                        $payload .= Binary::writeLTriad($last);
 
   57                        $start = $last = $current;
 
   64                $payload .= chr(self::RECORD_TYPE_SINGLE);
 
   65                $payload .= Binary::writeLTriad($start);
 
   67                $payload .= chr(self::RECORD_TYPE_RANGE);
 
   68                $payload .= Binary::writeLTriad($start);
 
   69                $payload .= Binary::writeLTriad($last);
 
   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();