| 115 | } |
| 116 | |
| 117 | void server_loop(RNS::Destination& destination) { |
| 118 | RNS::logf(RNS::LOG_NOTICE, |
| 119 | "NomadNet example node <%s> running, serving %s", |
| 120 | destination.hash().toHex().c_str(), DEFAULT_PAGE_PATH); |
| 121 | RNS::log("Hit enter to re-announce (Ctrl-C to quit)"); |
| 122 | |
| 123 | const RNS::Bytes node_name_app_data(NODE_NAME); |
| 124 | |
| 125 | while (true) { |
| 126 | reticulum.loop(); |
| 127 | // Non-blocking input |
| 128 | char ch; |
| 129 | while (read(STDIN_FILENO, &ch, 1) > 0) { |
| 130 | if (ch == '\n') { |
| 131 | destination.announce(node_name_app_data); |
| 132 | RNS::logf(RNS::LOG_NOTICE, "Sent announce from %s as \"%s\"", |
| 133 | destination.hash().toHex().c_str(), NODE_NAME); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | void server() { |
| 140 | |