RDFS
The Rice Comp413 2017 class' continuation on the work of the 2016 RDFS.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
RPCServer Class Reference

Public Member Functions

 RPCServer (int port)
 
void serve (asio::io_service &io_service)
 
void register_handler (std::string key, std::function< std::string(std::string)> handler)
 
std::string getUsername ()
 

Constructor & Destructor Documentation

RPCServer::RPCServer ( int  port)
explicit

Construct an RPC server that will listen on given port.

Member Function Documentation

std::string RPCServer::getUsername ( )

Returns the name of the current running linux user.

Returns
A string of the current user's name

Returns the current user's name.

void RPCServer::register_handler ( std::string  key,
std::function< std::string(std::string)>  handler 
)

Register a handler function for the given key, such that when a request for method of name key arrives, the registered handler is called.

Parameters
keyis the method name specified in the request header.
handlertakes as input a string the bytes of the method's input protobuf, and should return a string of bytes of the method's output protobuf (so the handler should parse and serialize protobufs)

Register given handler function on the provided method key. The function's input will be a string of bytes corresponding to the Proto of its input. Exepct the function to return a string of serialized bytes of its specified output Proto.

void RPCServer::serve ( asio::io_service &  io_service)

Begin the listen-loop of the RPC server. This method does not return.

Begin the server's main listen loop using provided io service.


The documentation for this class was generated from the following files: