The Request-Response Operation
The code below is an excerpt from WeatherSummaryImp.cpp. It shows the message handler registration macro and the endpoint implementation for the request-response operation method subscribe().
 
RWSF_DEFINE_MESSAGE_HANDLER(WeatherSummaryImp)
 
void
WeatherSummaryImp::subscribe(rwsf::CallInfo& callInfo,
const std::string& host_in, const std::string& port_in,
const std::string& transportName_in,
bool& status_out, std::string& message_out) //1
{
std::string location = createLocation(transportName_in,
host_in, port_in); //2
 
WeatherSummaryNotificationProxy notifProxy =
WeatherSummaryNotificationProxy::make(location); //3
bool result = notifProxy.verifySubscription(); //4
 
if (result) { //5
subscriptions_.insert(subscriptions_.end(), location);
message_out = "OK";
}
else {
message_out = "Unable to verify callback server.";
}
status_out = result;
}
//1 The call to the subscribe() operation method. The CallInfo object contains data related to message handling and configuration properties. The next three parameters are passed from the client request, and the final two are to hold data sent in the response.
//2 Creates a location based on the input parameters. The createLocation() method is also defined in this file.
//3 Obtains an instance of the notification proxy, which is the client-like proxy that allows the server to initiate requests.
//4 Calls the verifySubscription() solicit-response operation method, which verifies that the location created above is real and reachable.
//5 The remaining lines of code use the result of the verifySubscription() call to set the status and message return data.
This file also defines the unsubscribe() operation method, which is very similar to above except for the logic that determines the response data. See the WeatherSummaryImp.cpp file in the example if you are interested in the specifics.