improve example
This commit is contained in:
+6
-1
@@ -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,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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user