小编Ari*_*jar的帖子

如何在 gRPC 角度应用程序中使用 typescript protobuf 生成的文件

总结问题

我正在学习如何使用 gRPC,并想尝试进行客户端-服务器连接。服务器(在 Elixir 中)可以工作,但我遇到了一些问题。但由于我主要是一名后端开发人员,我在 Angular 中实现它时遇到了更多的麻烦,希望得到一些帮助。

我在这个项目中使用Angular 8.2.9Angular CLI 8.3.8Node 10.16.0

我已经做了什么?

  1. 创建了一个新的 angular cli 项目 ng new test-grpc
  2. 使用 生成了一个模块和一个组件ng g...,并修改基本路由以具有工作页面和 url。
  3. 已安装的 Protobuf 和 gRPC 库 npm install @improbable-eng/grpc-web @types/google-protobuf google-protobuf grpc-web-client protoc ts-protoc-gen --save
  4. .proto从我的 Elixir 代码中取出文件并将其复制到一个文件夹中src/proto
  5. protoc在 package.json 中添加了一条命令scripts "protoc": "protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts.cmd --js_out=import_style=commonjs,binary:src/app/proto-gen --ts_out=service=true:src/app/proto-ts -I ./src/proto/ ./src/proto/*.proto"
  6. 叫命令生成中发现的js和TS文件src/app/proto-tssrc/app/proto-js
  7. 更换了任何_-所生成的文件的名称。
  8. 然后我尝试在 ngOnInit 中添加以下代码:https : //github.com/improbable-eng/grpc-web/tree/master/client/grpc-web#usage-overview …

protocol-buffers typescript protobuf.js angular grpc-web

9
推荐指数
1
解决办法
8897
查看次数

虚函数调用,parrent的函数使用

关于StackOverflow的第一个问题.我要为我糟糕的英语道歉.

我实际上正在为视频游戏开发一个菜单.我想清除代码,所以我想用vector来调用不同的函数(比如为图片充电或修改文本)

这是代码:

Menu.hh:

class Menu
{
int _position
std::vector<Menu> _graph;
std::list<sf::Text> _text;
public:
//constructors and destructors
virtual std::list<sf::Text> &modifyText();
}
Run Code Online (Sandbox Code Playgroud)

Menu.cpp

std::list<sf::Text> &modifyText()
{
std::cout << this->_position << std::endl;
this->_text = this->_graph[this->_position].modifyText();
return (this->_text); // don't care of the return
}

void Menu::initGame()
{
this->_graph.push_back(MenuBase()); 
// if i Put this code on the constructor, the constructor call himself and not the MenuBase constructor
this->modifyText();
}
Run Code Online (Sandbox Code Playgroud)

MenuBase.hpp

class MenuBase : public Menu
{
//constructor and destructor
std::list<sf::Text &modifyText(){std::cout << "work" …
Run Code Online (Sandbox Code Playgroud)

c++ virtual function sfml

1
推荐指数
1
解决办法
75
查看次数