260 $message =
new self();
261 $values = array_merge([
269 $message->setSender($values[
'sender']);
270 $message->setBody($values[
'body']);
271 $message->setExpiry($values[
'expiry']);
272 $message->setType($values[
'type']);
274 foreach ($values[
'receivers'] as $item) {
275 $message->addReceivers($item);
286 return \google\protobuf\DescriptorProto::fromArray([
287 'name' =>
'IncomingMessage',
289 \google\protobuf\FieldDescriptorProto::fromArray([
291 'name' =>
'receivers',
292 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(),
293 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(),
294 'type_name' =>
'.Receiver'
296 \google\protobuf\FieldDescriptorProto::fromArray([
299 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(),
300 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(),
301 'type_name' =>
'.Sender'
303 \google\protobuf\FieldDescriptorProto::fromArray([
306 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(),
307 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
309 \google\protobuf\FieldDescriptorProto::fromArray([
313 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
315 \google\protobuf\FieldDescriptorProto::fromArray([
318 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(),
319 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
343 public function writeTo(\Protobuf\WriteContext $context)
345 $stream = $context->getStream();
346 $writer = $context->getWriter();
347 $sizeContext = $context->getComputeSizeContext();
349 if ($this->receivers !==
null) {
350 foreach ($this->receivers as $val) {
351 $writer->writeVarint($stream, 10);
352 $writer->writeVarint($stream, $val->serializedSize($sizeContext));
353 $val->writeTo($context);
357 if ($this->sender !==
null) {
358 $writer->writeVarint($stream, 18);
359 $writer->writeVarint($stream, $this->sender->serializedSize($sizeContext));
360 $this->sender->writeTo($context);
363 if ($this->body !==
null) {
364 $writer->writeVarint($stream, 26);
365 $writer->writeString($stream, $this->body);
368 if ($this->expiry !==
null) {
369 $writer->writeVarint($stream, 32);
370 $writer->writeVarint($stream, $this->expiry);
373 if ($this->type !==
null) {
374 $writer->writeVarint($stream, 42);
375 $writer->writeString($stream, $this->type);
388 public function readFrom(\Protobuf\ReadContext $context)
390 $reader = $context->getReader();
391 $length = $context->getLength();
392 $stream = $context->getStream();
394 $limit = ($length !==
null)
395 ? ($stream->tell() + $length)
398 while ($limit ===
null || $stream->tell() < $limit) {
400 if ($stream->eof()) {
404 $key = $reader->readVarint($stream);
405 $wire = \Protobuf\WireFormat::getTagWireType($key);
406 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
408 if ($stream->eof()) {
413 \Protobuf\WireFormat::assertWireType($wire, 11);
415 $innerSize = $reader->readVarint($stream);
416 $innerMessage = new \Bitrix\Pull\Protobuf\Receiver();
418 if ($this->receivers ===
null) {
419 $this->receivers = new \Protobuf\MessageCollection();
422 $this->receivers->add($innerMessage);
424 $context->setLength($innerSize);
425 $innerMessage->readFrom($context);
426 $context->setLength($length);
432 \Protobuf\WireFormat::assertWireType($wire, 11);
434 $innerSize = $reader->readVarint($stream);
435 $innerMessage = new \Bitrix\Pull\Protobuf\Sender();
437 $this->sender = $innerMessage;
439 $context->setLength($innerSize);
440 $innerMessage->readFrom($context);
441 $context->setLength($length);
447 \Protobuf\WireFormat::assertWireType($wire, 9);
449 $this->body = $reader->readString($stream);
455 \Protobuf\WireFormat::assertWireType($wire, 13);
457 $this->expiry = $reader->readVarint($stream);
463 \Protobuf\WireFormat::assertWireType($wire, 9);
465 $this->type = $reader->readString($stream);
473 if ($extension !==
null) {
474 $this->
extensions()->add($extension, $extension->readFrom($context, $wire));
483 $data = $reader->readUnknown($stream, $wire);
484 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
496 $calculator = $context->getSizeCalculator();
499 if ($this->receivers !==
null) {
500 foreach ($this->receivers as $val) {
501 $innerSize = $val->serializedSize($context);
505 $size += $calculator->computeVarintSize($innerSize);
509 if ($this->sender !==
null) {
510 $innerSize = $this->sender->serializedSize($context);
514 $size += $calculator->computeVarintSize($innerSize);
517 if ($this->body !==
null) {
519 $size += $calculator->computeStringSize($this->body);
522 if ($this->expiry !==
null) {
524 $size += $calculator->computeVarintSize($this->expiry);
527 if ($this->type !==
null) {
529 $size += $calculator->computeStringSize($this->type);
533 $size += $this->
extensions->serializedSize($context);
557 throw new \InvalidArgumentException(sprintf(
'Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
560 $this->receivers = ($message->receivers !==
null) ? $message->receivers :
$this->receivers;
561 $this->sender = ($message->sender !==
null) ? $message->sender :
$this->sender;
562 $this->body = ($message->body !==
null) ? $message->body :
$this->body;
563 $this->expiry = ($message->expiry !==
null) ? $message->expiry :
$this->expiry;
564 $this->type = ($message->type !==
null) ? $message->type :
$this->type;