#include "options.hpp"
#include "proton/io.hpp"
#include "proton/url.hpp"
#include "proton/event.hpp"
#include "proton/handler.hpp"
#include "proton/connection.hpp"
#include <iostream>
#include <vector>
private:
std::vector<std::string> requests;
public:
client(
const proton::url &u,
const std::vector<std::string>& r) : url(u), requests(r) {}
}
void send_request() {
req.
body(requests.front());
req.
reply_to(receiver.remote_source().address());
sender.send(req);
}
if (e.
link() == receiver)
send_request();
}
if (requests.empty()) return;
std::cout << requests.front() <<
" => " << response.
body() << std::endl;
requests.erase(requests.begin());
if (!requests.empty()) {
send_request();
} else {
}
}
};
int main(int argc, char **argv) {
std::string address("127.0.0.1:5672/examples");
options opts(argc, argv);
opts.add_value(address, 'a', "address", "connect and send to URL", "URL");
try {
opts.parse();
std::vector<std::string> requests;
requests.push_back("Twas brillig, and the slithy toves");
requests.push_back("Did gire and gymble in the wabe.");
requests.push_back("All mimsy were the borogroves,");
requests.push_back("And the mome raths outgrabe.");
client handler(address, requests);
return 0;
} catch (const bad_option& e) {
std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
return 1;
}