/CppRpcLight

C++ RPC based on boost.asio, boost.serialization and other boost libraries for reflection

Primary LanguageC++

CppRpcLight

Code example for CoreHard summer conference 2016.

How to build example

  1. Install Visual Studio 2015
  2. Extract prebuilt boost library archive in ThirdParty directory (ThirdParty\boost\1.60.0\)
  3. Open Src/CppRpcLight.sln solution in Visual Studio 2015
  4. Build RpcServer and RpcClient applications
  5. Run RpcServer than run RpcServer

Code example

Define service interface in server application (Service.h):

RPC_DEFINE(sum, int, int, int);
RPC_DEFINE(echo, std::string, std::string);

Declare service implementation in server application (Service.cpp):

#include "Service.h"

RPC_DECLARE(sum, int, int a, int b) {
    return a + b;
}

RPC_DECLARE(echo, std::string, std::string str) {
    return "-->" + str;
}

Add Service.h file to client application and call remove functions:

// Blocked call
std::string echo_result = echo(client_connection, std::string("Ping!"));
std::cout << echo_result << std::endl;

// Async call
std::future<std::string> echo_future = echo_async(client_connection, std::string("Ping!"));
std::cout << echo_future.get() << std::endl;

Contact info

If you have any questions, feel free to contact me at gomons@gmail.com