The Request-Response Service Operation Call
As another part of client initialization, the subscribe()method sends location and transport information to the weather service so the client can receive weather updates via its listener.
// set up the service proxy
rwsf::Transport transport; //1
if (transportName.empty()) {
transport = rwsf::TransportManager::findTransportByUrl(location);
} else {
transport = rwsf::TransportManager::findTransport(transportName);
}
WeatherSummaryProxy proxy = WeatherSummaryProxy::make(transport); //2
// subscribe to the WeatherSummary service.
std::cout << "Subscribing to WeatherSummary service..." << std::endl;
std::string host = listener.getProperty("bound-ip"); //3
std::string port = listener.getProperty("bound-port");
std::string scheme = listener.getProperty("name");
bool status; //4
std::string msg;
proxy.subscribe(host, port, scheme, status, msg); //5
if (status) { //6
std::cout << "Subscription successful." << std::endl;
}
else {
std::cerr << "Subscription failed: " << msg << std::endl;
return 1;
}
The client also implements an unsubscribe() method that is very similar to subscribe().