Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
incomingmessage.php
1<?
2
4
15class IncomingMessage extends \Protobuf\AbstractMessage
16{
17
21 protected $unknownFieldSet = null;
22
26 protected $extensions = null;
27
33 protected $receivers = null;
34
40 protected $sender = null;
41
47 protected $body = null;
48
54 protected $expiry = null;
55
61 protected $type = null;
62
68 public function hasReceiversList()
69 {
70 return $this->receivers !== null;
71 }
72
78 public function getReceiversList()
79 {
80 return $this->receivers;
81 }
82
88 public function setReceiversList(\Protobuf\Collection $value = null)
89 {
90 $this->receivers = $value;
91 }
92
98 public function addReceivers(\Bitrix\Pull\Protobuf\Receiver $value)
99 {
100 if ($this->receivers === null) {
101 $this->receivers = new \Protobuf\MessageCollection();
102 }
103
104 $this->receivers->add($value);
105 }
106
112 public function hasSender()
113 {
114 return $this->sender !== null;
115 }
116
122 public function getSender()
123 {
124 return $this->sender;
125 }
126
132 public function setSender(\Bitrix\Pull\Protobuf\Sender $value = null)
133 {
134 $this->sender = $value;
135 }
136
142 public function hasBody()
143 {
144 return $this->body !== null;
145 }
146
152 public function getBody()
153 {
154 return $this->body;
155 }
156
162 public function setBody($value = null)
163 {
164 $this->body = $value;
165 }
166
172 public function hasExpiry()
173 {
174 return $this->expiry !== null;
175 }
176
182 public function getExpiry()
183 {
184 return $this->expiry;
185 }
186
192 public function setExpiry($value = null)
193 {
194 $this->expiry = $value;
195 }
196
202 public function hasType()
203 {
204 return $this->type !== null;
205 }
206
212 public function getType()
213 {
214 return $this->type;
215 }
216
222 public function setType($value = null)
223 {
224 $this->type = $value;
225 }
226
230 public function extensions()
231 {
232 if ( $this->extensions !== null) {
233 return $this->extensions;
234 }
235
236 return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
237 }
238
242 public function unknownFieldSet()
243 {
245 }
246
250 public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
251 {
252 return new self($stream, $configuration);
253 }
254
258 public static function fromArray(array $values)
259 {
260 $message = new self();
261 $values = array_merge([
262 'receivers' => [],
263 'sender' => null,
264 'body' => null,
265 'expiry' => null,
266 'type' => null
267 ], $values);
268
269 $message->setSender($values['sender']);
270 $message->setBody($values['body']);
271 $message->setExpiry($values['expiry']);
272 $message->setType($values['type']);
273
274 foreach ($values['receivers'] as $item) {
275 $message->addReceivers($item);
276 }
277
278 return $message;
279 }
280
284 public static function descriptor()
285 {
286 return \google\protobuf\DescriptorProto::fromArray([
287 'name' => 'IncomingMessage',
288 'field' => [
289 \google\protobuf\FieldDescriptorProto::fromArray([
290 'number' => 1,
291 'name' => 'receivers',
292 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(),
293 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(),
294 'type_name' => '.Receiver'
295 ]),
296 \google\protobuf\FieldDescriptorProto::fromArray([
297 'number' => 2,
298 'name' => 'sender',
299 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(),
300 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(),
301 'type_name' => '.Sender'
302 ]),
303 \google\protobuf\FieldDescriptorProto::fromArray([
304 'number' => 3,
305 'name' => 'body',
306 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(),
307 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
308 ]),
309 \google\protobuf\FieldDescriptorProto::fromArray([
310 'number' => 4,
311 'name' => 'expiry',
312 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_UINT32(),
313 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
314 ]),
315 \google\protobuf\FieldDescriptorProto::fromArray([
316 'number' => 5,
317 'name' => 'type',
318 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(),
319 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
320 ]),
321 ],
322 ]);
323 }
324
328 public function toStream(\Protobuf\Configuration $configuration = null)
329 {
330 $config = $configuration ?: \Protobuf\Configuration::getInstance();
331 $context = $config->createWriteContext();
332 $stream = $context->getStream();
333
334 $this->writeTo($context);
335 $stream->seek(0);
336
337 return $stream;
338 }
339
343 public function writeTo(\Protobuf\WriteContext $context)
344 {
345 $stream = $context->getStream();
346 $writer = $context->getWriter();
347 $sizeContext = $context->getComputeSizeContext();
348
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);
354 }
355 }
356
357 if ($this->sender !== null) {
358 $writer->writeVarint($stream, 18);
359 $writer->writeVarint($stream, $this->sender->serializedSize($sizeContext));
360 $this->sender->writeTo($context);
361 }
362
363 if ($this->body !== null) {
364 $writer->writeVarint($stream, 26);
365 $writer->writeString($stream, $this->body);
366 }
367
368 if ($this->expiry !== null) {
369 $writer->writeVarint($stream, 32);
370 $writer->writeVarint($stream, $this->expiry);
371 }
372
373 if ($this->type !== null) {
374 $writer->writeVarint($stream, 42);
375 $writer->writeString($stream, $this->type);
376 }
377
378 if ($this->extensions !== null) {
379 $this->extensions->writeTo($context);
380 }
381
382 return $stream;
383 }
384
388 public function readFrom(\Protobuf\ReadContext $context)
389 {
390 $reader = $context->getReader();
391 $length = $context->getLength();
392 $stream = $context->getStream();
393
394 $limit = ($length !== null)
395 ? ($stream->tell() + $length)
396 : null;
397
398 while ($limit === null || $stream->tell() < $limit) {
399
400 if ($stream->eof()) {
401 break;
402 }
403
404 $key = $reader->readVarint($stream);
405 $wire = \Protobuf\WireFormat::getTagWireType($key);
406 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
407
408 if ($stream->eof()) {
409 break;
410 }
411
412 if ($tag === 1) {
413 \Protobuf\WireFormat::assertWireType($wire, 11);
414
415 $innerSize = $reader->readVarint($stream);
416 $innerMessage = new \Bitrix\Pull\Protobuf\Receiver();
417
418 if ($this->receivers === null) {
419 $this->receivers = new \Protobuf\MessageCollection();
420 }
421
422 $this->receivers->add($innerMessage);
423
424 $context->setLength($innerSize);
425 $innerMessage->readFrom($context);
426 $context->setLength($length);
427
428 continue;
429 }
430
431 if ($tag === 2) {
432 \Protobuf\WireFormat::assertWireType($wire, 11);
433
434 $innerSize = $reader->readVarint($stream);
435 $innerMessage = new \Bitrix\Pull\Protobuf\Sender();
436
437 $this->sender = $innerMessage;
438
439 $context->setLength($innerSize);
440 $innerMessage->readFrom($context);
441 $context->setLength($length);
442
443 continue;
444 }
445
446 if ($tag === 3) {
447 \Protobuf\WireFormat::assertWireType($wire, 9);
448
449 $this->body = $reader->readString($stream);
450
451 continue;
452 }
453
454 if ($tag === 4) {
455 \Protobuf\WireFormat::assertWireType($wire, 13);
456
457 $this->expiry = $reader->readVarint($stream);
458
459 continue;
460 }
461
462 if ($tag === 5) {
463 \Protobuf\WireFormat::assertWireType($wire, 9);
464
465 $this->type = $reader->readString($stream);
466
467 continue;
468 }
469
470 $extensions = $context->getExtensionRegistry();
471 $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
472
473 if ($extension !== null) {
474 $this->extensions()->add($extension, $extension->readFrom($context, $wire));
475
476 continue;
477 }
478
479 if ($this->unknownFieldSet === null) {
480 $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
481 }
482
483 $data = $reader->readUnknown($stream, $wire);
484 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
485
486 $this->unknownFieldSet->add($unknown);
487
488 }
489 }
490
494 public function serializedSize(\Protobuf\ComputeSizeContext $context)
495 {
496 $calculator = $context->getSizeCalculator();
497 $size = 0;
498
499 if ($this->receivers !== null) {
500 foreach ($this->receivers as $val) {
501 $innerSize = $val->serializedSize($context);
502
503 $size += 1;
504 $size += $innerSize;
505 $size += $calculator->computeVarintSize($innerSize);
506 }
507 }
508
509 if ($this->sender !== null) {
510 $innerSize = $this->sender->serializedSize($context);
511
512 $size += 1;
513 $size += $innerSize;
514 $size += $calculator->computeVarintSize($innerSize);
515 }
516
517 if ($this->body !== null) {
518 $size += 1;
519 $size += $calculator->computeStringSize($this->body);
520 }
521
522 if ($this->expiry !== null) {
523 $size += 1;
524 $size += $calculator->computeVarintSize($this->expiry);
525 }
526
527 if ($this->type !== null) {
528 $size += 1;
529 $size += $calculator->computeStringSize($this->type);
530 }
531
532 if ($this->extensions !== null) {
533 $size += $this->extensions->serializedSize($context);
534 }
535
536 return $size;
537 }
538
542 public function clear()
543 {
544 $this->receivers = null;
545 $this->sender = null;
546 $this->body = null;
547 $this->expiry = null;
548 $this->type = null;
549 }
550
554 public function merge(\Protobuf\Message $message)
555 {
556 if ( ! $message instanceof \Bitrix\Pull\Protobuf\IncomingMessage) {
557 throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
558 }
559
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;
565 }
566
567
568}
569
writeTo(\Protobuf\WriteContext $context)
setSender(\Bitrix\Pull\Protobuf\Sender $value=null)
toStream(\Protobuf\Configuration $configuration=null)
serializedSize(\Protobuf\ComputeSizeContext $context)
addReceivers(\Bitrix\Pull\Protobuf\Receiver $value)
merge(\Protobuf\Message $message)
static fromStream($stream, \Protobuf\Configuration $configuration=null)
setReceiversList(\Protobuf\Collection $value=null)
readFrom(\Protobuf\ReadContext $context)