improve example

This commit is contained in:
Сергей Маринкевич
2025-12-04 13:48:01 +07:00
parent 0334b9a42b
commit 31d0496a93
3 changed files with 14 additions and 3 deletions
+6 -1
View File
@@ -1,5 +1,10 @@
#include "MyService.h"
int MyService::add(int a, int b) {
return a + b;
counter_ += (a + b);
return counter_;
}
int MyService::get() {
return counter_;
}
+5
View File
@@ -5,8 +5,13 @@
// annotate with clang attribute or via comment annotation recognized by libclang
// Use ANNOTATE attribute supported by clang: __attribute__((annotate("export")))
class RPC_EXPORT MyService {
private:
int counter_ = 0;
public:
RPC_EXPORT
int add(int a, int b);
RPC_EXPORT
int get();
int minus(int a, int b);
};
+3 -2
View File
@@ -20,6 +20,7 @@ int main() {
ProxyMarshaller marshaller(ch);
MyServiceProxy proxy(marshaller);
int r = proxy.add(7, 9);
std::cout << "RESULT: " << r << std::endl;
proxy.add(7, 9);
int counter = proxy.get();
std::cout << "RESULT: " << counter << std::endl;
}