24using json = nlohmann::json;
60 zmq::multipart_t message;
61 string payload, compressed;
62 regex re(
"^(\\w+):\\s*(\\{.*\\})\\s*$");
65 while (getline(cin, payload)) {
66 if (payload ==
"exit") {
67 Mads::Runtime::stop_process();
70 if (regex_search(payload, match, re) && match.size() > 1) {
74 cout <<
"Topic: " <<
_pub_topic <<
", Payload: " << payload << endl;
76 j = json::parse(payload);
78 }
catch (
const std::exception &e) {
79 cerr <<
"Failed to parse JSON: " << e.what() << endl;
92 void load_settings()
override {
std::string name()
Returns the name of the agent.
void publish(nlohmann::json payload, std::string topic="")
Publishes a message with the given JSON payload.
The Bridge class represents metadata for an agent.
void route()
Routes any line received via STDIN to the mads network.
Bridge(std::string name, std::string settings_path)
Constructs a Bridge object with the given name and settings path.