Cap'n Proto C++ RPC와의 약속 된 파이프 라이닝을 시도하고 싶습니다만 어떻게해야할지 모르겠습니다.Cap'n Proto 및 약속 파이프 라이닝
auto request1 = test.getIntRequest();
auto promise = request1.send();
auto request2 = test.incrementRequest();
request2.setIntParam(promise.getIntResult()) // HERE IS THE PROBLEM
auto promise2 = request2.send();
:
increment(getInt());
내가 그런 일을하려고 노력 :
여기interface Test {
getInt @0() -> (intResult :Int32);
increment @1 (intParam :Int32) -> (intResult :Int32);
}
내가 (의사 코드)를 수행하고자하는 것입니다 : 여기
내 스키마입니다하지만 약속을 사용하는 것은 좋지 않습니다. 내가하고 싶은 것을 이해하기를 바랍니다.
감사합니다.
EDIT : 다른 질문 : 서버에서 메소드를 구현하는 방법은 무엇입니까?
이 나는이 코드를 작성했습니다 :
#include <kj/debug.h>
#include <capnp/ez-rpc.h>
#include <capnp/message.h>
#include <iostream>
#include "test.capnp.h"
using namespace std;
class TestI : virtual public Test::Server
{
public:
TestI() {}
::kj::Promise<void> getInt(GetIntContext context)
{
// ????
}
::kj::Promise<void> increment(IncrementContext context)
{
// ????
}
};
class Int32BoxI : virtual public Int32Box::Server
{
private:
int val = 12;
public:
Int32BoxI(int value): val(value) {}
::kj::Promise<void> get(GetContext context)
{
context.getResults().setValue(this->val);
return kj::READY_NOW;
}
}
하지만 난의 getInt() 및 증가()을 구현하는 방법을 모르겠어요.
답변 해 주셔서 감사합니다. 지금은 분명합니다. 그러나 서버에서 메서드를 구현하는 데 어려움이 있습니다. 나는 나의 문제를 보여주기 위해 나의 첫 번째 글을 편집했다. 다시 감사합니다. –
@ B.Clement Cap'n Proto 저장소의 "계산기"예제를 확인하는 것이 좋습니다. 이는 여러분이하고있는 것과 매우 유사합니다. 참조 : https://github.com/sandstorm-io/capnproto/tree/master/c++/samples –