本文整理汇总了PHP中Protobuf\WireFormat类的典型用法代码示例。如果您正苦于以下问题:PHP WireFormat类的具体用法?PHP WireFormat怎么用?PHP WireFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WireFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genericServices
/**
* Extension field : generic_services
*
* @return \Protobuf\Extension
*/
public static function genericServices()
{
if (self::$generic_services !== null) {
return self::$generic_services;
}
$readCallback = function (\Protobuf\ReadContext $context, $wire) {
$reader = $context->getReader();
$length = $context->getLength();
$stream = $context->getStream();
\Protobuf\WireFormat::assertWireType($wire, 8);
$value = $reader->readBool($stream);
return $value;
};
$writeCallback = function (\Protobuf\WriteContext $context, $value) {
$stream = $context->getStream();
$writer = $context->getWriter();
$sizeContext = $context->getComputeSizeContext();
$writer->writeVarint($stream, 400024);
$writer->writeBool($stream, $value);
};
$sizeCallback = function (\Protobuf\ComputeSizeContext $context, $value) {
$calculator = $context->getSizeCalculator();
$size = 0;
$size += 3;
$size += 1;
return $size;
};
return self::$generic_services = new \Protobuf\Extension\ExtensionField('\\google\\protobuf\\FileOptions', 'generic_services', 50003, $readCallback, $writeCallback, $sizeCallback, __METHOD__);
}
示例2: assertWireType
/**
* Assert the wire type match
*
* @param integer $wire
* @param integer $type
*/
public static function assertWireType($wire, $type)
{
$expected = WireFormat::getWireType($type, $wire);
if ($wire !== $expected) {
throw new RuntimeException(sprintf("Expected wire type %s but got %s for type %s.", $expected, $wire, $type));
}
}
示例3: assertNextTagWire
protected function assertNextTagWire(StreamReader $reader, Stream $stream, $expectedTag, $expectedWire)
{
$key = $reader->readVarint($stream);
$tag = WireFormat::getTagFieldNumber($key);
$wire = WireFormat::getTagWireType($key);
$this->assertEquals($expectedTag, $tag);
$this->assertEquals($expectedWire, $wire);
}
示例4: testWriteStream
public function testWriteStream()
{
$source = Stream::create();
$target = Stream::create();
$writer = new StreamWriter($this->config);
$writer->writeVarint($source, WireFormat::getFieldKey(1, WireFormat::WIRE_FIXED64));
$writer->writeDouble($source, 123456789.12345);
$source->seek(0);
$writer->writeStream($target, $source);
$this->assertEquals((string) $source, (string) $target);
}
示例5: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->incense_type = \POGOProtos\Inventory\Item\ItemId::valueOf($reader->readVarint($stream));
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例6: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 4);
$this->start_time_ms = $reader->readVarint($stream);
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->unknown_status = $reader->readBool($stream);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->walking = $reader->readBool($stream);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->running = $reader->readBool($stream);
continue;
}
if ($tag === 5) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->stationary = $reader->readBool($stream);
continue;
}
if ($tag === 6) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->automotive = $reader->readBool($stream);
continue;
}
if ($tag === 7) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->tilting = $reader->readBool($stream);
continue;
}
if ($tag === 8) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->cycling = $reader->readBool($stream);
continue;
}
if ($tag === 9) {
\Protobuf\WireFormat::assertWireType($wire, 12);
$this->status = $reader->readByteStream($stream);
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例7: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->buckets_per_day = $reader->readVarint($stream);
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->streak_length = $reader->readVarint($stream);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->bonus_multiplier = $reader->readFloat($stream);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->streak_bonus_multiplier = $reader->readFloat($stream);
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例8: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 9);
$this->fort_id = $reader->readString($stream);
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 6);
$this->encounter_id = $reader->readFixed64($stream);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->active_pokemon_id = \POGOProtos\Enums\PokemonId::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 3);
$this->lure_expires_timestamp_ms = $reader->readVarint($stream);
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例9: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->energy_per_sec = $reader->readFloat($stream);
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->dodge_energy_cost = $reader->readFloat($stream);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->retarget_seconds = $reader->readFloat($stream);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->enemy_attack_interval = $reader->readFloat($stream);
continue;
}
if ($tag === 5) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->attack_server_interval = $reader->readFloat($stream);
continue;
}
if ($tag === 6) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->round_duration_seconds = $reader->readFloat($stream);
continue;
}
if ($tag === 7) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->bonus_time_per_ally_seconds = $reader->readFloat($stream);
continue;
}
if ($tag === 8) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->maximum_attackers_per_battle = $reader->readVarint($stream);
continue;
}
if ($tag === 9) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->same_type_attack_bonus_multiplier = $reader->readFloat($stream);
continue;
}
if ($tag === 10) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->maximum_energy = $reader->readVarint($stream);
continue;
}
if ($tag === 11) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->energy_delta_per_health_lost = $reader->readFloat($stream);
continue;
}
if ($tag === 12) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->dodge_duration_ms = $reader->readVarint($stream);
continue;
}
if ($tag === 13) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->minimum_player_level = $reader->readVarint($stream);
continue;
}
if ($tag === 14) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->swap_duration_ms = $reader->readVarint($stream);
continue;
}
if ($tag === 15) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->dodge_damage_reduction_percent = $reader->readFloat($stream);
continue;
}
$extensions = $context->getExtensionRegistry();
$extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
if ($extension !== null) {
$this->extensions()->add($extension, $extension->readFrom($context, $wire));
continue;
}
//.........这里部分代码省略.........
示例10: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->result = \POGOProtos\Networking\Responses\StartGymBattleResponse\Result::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 3);
$this->battle_start_timestamp_ms = $reader->readVarint($stream);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 3);
$this->battle_end_timestamp_ms = $reader->readVarint($stream);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 9);
$this->battle_id = $reader->readString($stream);
continue;
}
if ($tag === 5) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Data\Battle\BattleParticipant();
$this->defender = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 6) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Data\Battle\BattleLog();
$this->battle_log = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 7) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Data\Battle\BattleParticipant();
$this->attacker = $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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例11: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->result = \POGOProtos\Networking\Responses\LevelUpRewardsResponse\Result::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Inventory\Item\ItemAward();
if ($this->items_awarded === null) {
$this->items_awarded = new \Protobuf\MessageCollection();
}
$this->items_awarded->add($innerMessage);
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 4) {
$innerSize = $reader->readVarint($stream);
$innerLimit = $stream->tell() + $innerSize;
if ($this->items_unlocked === null) {
$this->items_unlocked = new \Protobuf\EnumCollection();
}
while ($stream->tell() < $innerLimit) {
$this->items_unlocked->add(\POGOProtos\Inventory\Item\ItemId::valueOf($reader->readVarint($stream)));
}
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例12: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \google\protobuf\UninterpretedOption\NamePart();
if ($this->name === null) {
$this->name = new \Protobuf\MessageCollection();
}
$this->name->add($innerMessage);
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 9);
$this->identifier_value = $reader->readString($stream);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 4);
$this->positive_int_value = $reader->readVarint($stream);
continue;
}
if ($tag === 5) {
\Protobuf\WireFormat::assertWireType($wire, 3);
$this->negative_int_value = $reader->readVarint($stream);
continue;
}
if ($tag === 6) {
\Protobuf\WireFormat::assertWireType($wire, 1);
$this->double_value = $reader->readDouble($stream);
continue;
}
if ($tag === 7) {
\Protobuf\WireFormat::assertWireType($wire, 12);
$this->string_value = $reader->readByteStream($stream);
continue;
}
if ($tag === 8) {
\Protobuf\WireFormat::assertWireType($wire, 9);
$this->aggregate_value = $reader->readString($stream);
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例13: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 9);
$this->item_id = $reader->readString($stream);
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 8);
$this->is_iap = $reader->readBool($stream);
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Data\Player\Currency();
$this->currency_to_buy = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Data\Player\Currency();
$this->yields_currency = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 5) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Inventory\Item\ItemData();
$this->yields_item = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 6) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Networking\Platform\Responses\GetStoreItemsResponse\StoreItem\TagsEntry();
if ($this->tags === null) {
$this->tags = new \Protobuf\MessageCollection();
}
$this->tags->add($innerMessage);
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 7) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->unknown7 = $reader->readVarint($stream);
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}
示例14: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->pokemon_id = \POGOProtos\Enums\PokemonId::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 3) {
\Protobuf\WireFormat::assertWireType($wire, 2);
$this->model_scale = $reader->readFloat($stream);
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->type = \POGOProtos\Enums\PokemonType::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 5) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->type_2 = \POGOProtos\Enums\PokemonType::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 6) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Settings\Master\Pokemon\CameraAttributes();
$this->camera = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 7) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Settings\Master\Pokemon\EncounterAttributes();
$this->encounter = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 8) {
\Protobuf\WireFormat::assertWireType($wire, 11);
$innerSize = $reader->readVarint($stream);
$innerMessage = new \POGOProtos\Settings\Master\Pokemon\StatsAttributes();
$this->stats = $innerMessage;
$context->setLength($innerSize);
$innerMessage->readFrom($context);
$context->setLength($length);
continue;
}
if ($tag === 9) {
$innerSize = $reader->readVarint($stream);
$innerLimit = $stream->tell() + $innerSize;
if ($this->quick_moves === null) {
$this->quick_moves = new \Protobuf\EnumCollection();
}
while ($stream->tell() < $innerLimit) {
$this->quick_moves->add(\POGOProtos\Enums\PokemonMove::valueOf($reader->readVarint($stream)));
}
continue;
}
if ($tag === 10) {
$innerSize = $reader->readVarint($stream);
$innerLimit = $stream->tell() + $innerSize;
if ($this->cinematic_moves === null) {
$this->cinematic_moves = new \Protobuf\EnumCollection();
}
while ($stream->tell() < $innerLimit) {
$this->cinematic_moves->add(\POGOProtos\Enums\PokemonMove::valueOf($reader->readVarint($stream)));
}
continue;
}
if ($tag === 11) {
$innerSize = $reader->readVarint($stream);
$innerLimit = $stream->tell() + $innerSize;
if ($this->animation_time === null) {
$this->animation_time = new \Protobuf\ScalarCollection();
}
while ($stream->tell() < $innerLimit) {
$this->animation_time->add($reader->readFloat($stream));
}
//.........这里部分代码省略.........
示例15: readFrom
/**
* {@inheritdoc}
*/
public function readFrom(\Protobuf\ReadContext $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 = \Protobuf\WireFormat::getTagWireType($key);
$tag = \Protobuf\WireFormat::getTagFieldNumber($key);
if ($stream->eof()) {
break;
}
if ($tag === 1) {
\Protobuf\WireFormat::assertWireType($wire, 14);
$this->result = \POGOProtos\Networking\Responses\CollectDailyDefenderBonusResponse\Result::valueOf($reader->readVarint($stream));
continue;
}
if ($tag === 2) {
\Protobuf\WireFormat::assertWireType($wire, 9);
if ($this->currency_type === null) {
$this->currency_type = new \Protobuf\ScalarCollection();
}
$this->currency_type->add($reader->readString($stream));
continue;
}
if ($tag === 3) {
$innerSize = $reader->readVarint($stream);
$innerLimit = $stream->tell() + $innerSize;
if ($this->currency_awarded === null) {
$this->currency_awarded = new \Protobuf\ScalarCollection();
}
while ($stream->tell() < $innerLimit) {
$this->currency_awarded->add($reader->readVarint($stream));
}
continue;
}
if ($tag === 4) {
\Protobuf\WireFormat::assertWireType($wire, 5);
$this->defenders_count = $reader->readVarint($stream);
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 \Protobuf\UnknownFieldSet();
}
$data = $reader->readUnknown($stream, $wire);
$unknown = new \Protobuf\Unknown($tag, $wire, $data);
$this->unknownFieldSet->add($unknown);
}
}