有用过grpc的吗?Couldn't find descriptor

syntax = "proto3";
package protobuf;

message C2SAudio{
    bytes audio = 1;
}
message S2CAudio{
    bytes audio = 1;
   string account = 4;
}
<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: app/Proto/audio.proto

namespace Grpc;

use Google\Protobuf\Internal\GPBUtil;

/**
 * Generated from protobuf message <code>protobuf.C2SAudio</code>
 */
class C2SAudio extends \Google\Protobuf\Internal\Message
{
    /**
     * Generated from protobuf field <code>bytes audio = 1;</code>
     */
    protected $audio = '';

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $audio
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Audio::initOnce();
        parent::__construct($data);
    }

    /**
     * Generated from protobuf field <code>bytes audio = 1;</code>
     * @return string
     */
    public function getAudio()
    {
        return $this->audio;
    }

    /**
     * Generated from protobuf field <code>bytes audio = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setAudio($var)
    {
        GPBUtil::checkString($var, False);
        $this->audio = $var;

        return $this;
    }

}
<?php
/**
 * User: jesse * Date: 2023/8/7 15:31 */
namespace App\Service;

use Google\Protobuf\Internal\GPBUtil;

use Hyperf\Grpc\Parser;
use Grpc\C2SAudio;

class AudioService
{

  public function handle($fd, $content)
 {
  /** @var C2SAudio $audio */
  $audio = Parser::deserializeMessage([C2SAudio::class, null], $content);

  var_dump($audio->getAudio());

 return $content;
  }
}
[ERROR] Exception: Couldn't find descriptor. Note only generated code may derive from \Google\Protobuf\Internal\Message in /www/conversation/grpc/Protobuf/C2SAudio.php:30
Stack trace:
#0 /www/conversation/grpc/Protobuf/C2SAudio.php(30): Google\Protobuf\Internal\Message->__construct(NULL)
#1 /www/conversation/vendor/hyperf/grpc/src/Parser.php(102): Grpc\C2SAudio->__construct()
#2 /www/conversation/vendor/hyperf/grpc/src/Parser.php(50): Hyperf\Grpc\Parser::deserializeUnpackedMessage(Array, '\x05|\x00\x07\x00S\x00S\x00\x07\x00\r\x00\t\x00...')
#3 /www/conversation/app/Service/AudioService.php(22): Hyperf\Grpc\Parser::deserializeMessage(Array, '\x05|\x00\x07\x00S\x00S\x00\x07\x00\r\x00\t\x00...')
#4 /www/conversation/runtime/container/proxy/App_Controller_WebSocketController.proxy.php(43): App\Service\AudioService->handle(3, '\x05|\x00\x07\x00S\x00S\x00\x07\x00\r\x00\t\x00...')
#5 /www/conversation/vendor/hyperf/websocket-server/src/Server.php(208): App\Controller\WebSocketController->onMessage(Object(Swoole\WebSocket\Server), Object(Swoole\WebSocket\Frame))
#6 [internal function]: Hyperf\WebSocketServer\Server->onMessage(Object(Swoole\WebSocket\Server), Object(Swoole\WebSocket\Frame))
#7 {main}
<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: app/Proto/audio.proto

namespace GPBMetadata;

class Audio
{
  public static $is_initialized = false;

 public static function initOnce() {
  $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();

 if (static::$is_initialized == true) {
  return;
  }
  $pool->internalAddGeneratedFile(
  '
p
app/Proto/audio.protoprotobuf"
C2SAudio
audio ("*
S2CAudio
audio (
account (  bproto3'
  , true);

 static::$is_initialized = true;
  }
}
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 12

看错误提示,需要你检查下代码生成。\GPBMetadata\Audio 这个贴出来看一眼

1年前 评论
晏南风 (楼主) 1年前
Crayxn (作者) 1年前
Crayxn (作者) 1年前
晏南风 (楼主) 1年前
Crayxn (作者) 1年前

file

file

检查下 代码生成吧,应该是 代码生成问题。可以参考下 我的博文

1年前 评论
晏南风 (楼主) 1年前
晏南风 (楼主) 1年前
Es123 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!