The client part is almost equal to the single threaded version. The only thing you have to do is to provide an additional parameter which contains a method that handles the response. This can be a normal function or a member of an object:
TcpIpConnection conn (false, host, port); HttpProtocol prot(&conn); Requester client(&prot); MethodCall testcall ("testcall"); client.call(testcall, "/RPC2", make_receiver(receiver_func));
The call()
method sends the call and then
creates a thread to start this method which is expected to handle the
return value or maybe an error message. So the response handler should
look something like this:
void receiver_func (const MethodResponse &resp) { if (!resp.isOK()) { ... return; } Mutex::Locker locker(receiver_mutex); unsigned num = Integer(resp.getResult()).getInteger(); ... }
Create a receiver for the response. | |
Handle a potential error response. | |
Lock this area againt concurrent access if neccessary. | |
Extract and process the response values. |