我正在学习如何使用 gRPC,并想尝试进行客户端-服务器连接。服务器(在 Elixir 中)可以工作,但我遇到了一些问题。但由于我主要是一名后端开发人员,我在 Angular 中实现它时遇到了更多的麻烦,希望得到一些帮助。
我在这个项目中使用Angular 8.2.9、Angular CLI 8.3.8和Node 10.16.0。
ng new test-grpcng g...,并修改基本路由以具有工作页面和 url。npm install @improbable-eng/grpc-web @types/google-protobuf google-protobuf grpc-web-client protoc ts-protoc-gen --save.proto从我的 Elixir 代码中取出文件并将其复制到一个文件夹中src/protoprotoc在 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"src/app/proto-ts和src/app/proto-js_与-所生成的文件的名称。关于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)