• Модуль: pull
  • Путь к файлу: ~/bitrix/modules/pull/lib/protobuf/responsebatch.php
  • Класс: BitrixPullProtobufResponseBatch
  • Вызов: ResponseBatch::readFrom
public function readFrom(ProtobufReadContext $context)
    {
        $reader = $context->getReader();
        $length = $context->getLength();
        $stream = $context->getStream();

        $limit = ($length !== null)
            ? ($stream->tell() + $length)
            : null;

        while ($limit === null || $stream->tell() < $limit) {

            if ($stream->eof()) {
                break;
            }

            $key  = $reader->readVarint($stream);
            $wire = ProtobufWireFormat::getTagWireType($key);
            $tag  = ProtobufWireFormat::getTagFieldNumber($key);

            if ($stream->eof()) {
                break;
            }

            if ($tag === 1) {
                ProtobufWireFormat::assertWireType($wire, 11);

                $innerSize    = $reader->readVarint($stream);
                $innerMessage = new BitrixPullProtobufResponse();

                if ($this->responses === null) {
                    $this->responses = new ProtobufMessageCollection();
                }

                $this->responses->add($innerMessage);

                $context->setLength($innerSize);
                $innerMessage->readFrom($context);
                $context->setLength($length);

                continue;
            }

            $extensions = $context->getExtensionRegistry();
            $extension  = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;

            if ($extension !== null) {
                $this->extensions()->add($extension, $extension->readFrom($context, $wire));

                continue;
            }

            if ($this->unknownFieldSet === null) {
                $this->unknownFieldSet = new ProtobufUnknownFieldSet();
            }

            $data    = $reader->readUnknown($stream, $wire);
            $unknown = new ProtobufUnknown($tag, $wire, $data);

            $this->unknownFieldSet->add($unknown);

        }
    }