improve example
This commit is contained in:
+6
-1
@@ -1,5 +1,10 @@
|
|||||||
#include "MyService.h"
|
#include "MyService.h"
|
||||||
|
|
||||||
int MyService::add(int a, int b) {
|
int MyService::add(int a, int b) {
|
||||||
return a + b;
|
counter_ += (a + b);
|
||||||
|
return counter_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MyService::get() {
|
||||||
|
return counter_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,13 @@
|
|||||||
// annotate with clang attribute or via comment annotation recognized by libclang
|
// annotate with clang attribute or via comment annotation recognized by libclang
|
||||||
// Use ANNOTATE attribute supported by clang: __attribute__((annotate("export")))
|
// Use ANNOTATE attribute supported by clang: __attribute__((annotate("export")))
|
||||||
class RPC_EXPORT MyService {
|
class RPC_EXPORT MyService {
|
||||||
|
private:
|
||||||
|
int counter_ = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RPC_EXPORT
|
RPC_EXPORT
|
||||||
int add(int a, int b);
|
int add(int a, int b);
|
||||||
|
RPC_EXPORT
|
||||||
|
int get();
|
||||||
int minus(int a, int b);
|
int minus(int a, int b);
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-2
@@ -20,6 +20,7 @@ int main() {
|
|||||||
ProxyMarshaller marshaller(ch);
|
ProxyMarshaller marshaller(ch);
|
||||||
MyServiceProxy proxy(marshaller);
|
MyServiceProxy proxy(marshaller);
|
||||||
|
|
||||||
int r = proxy.add(7, 9);
|
proxy.add(7, 9);
|
||||||
std::cout << "RESULT: " << r << std::endl;
|
int counter = proxy.get();
|
||||||
|
std::cout << "RESULT: " << counter << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user