| 168 | } |
| 169 | |
| 170 | void readInput(std::atomic<bool>& run) |
| 171 | { |
| 172 | std::string buffer; |
| 173 | |
| 174 | while (run.load()) |
| 175 | { |
| 176 | std::getline(std::cin, buffer); |
| 177 | |
| 178 | std::string command = toLower(buffer); |
| 179 | |
| 180 | if (command == "/quit") |
| 181 | { |
| 182 | run.store(false); |
| 183 | } else if (command.compare(0, 6, "/peer ") == 0) { |
| 184 | PeerId peer = strtoul(&command[6], NULL, 10); |
| 185 | if (peer != 0) { |
| 186 | connectToPeer(peer); |
| 187 | } else { |
| 188 | connectToPeer(humblenet_p2p_virtual_peer_for_alias( &command[6] ) ); |
| 189 | } |
| 190 | } else if (command.compare(0,7, "/alias ") == 0 ) { |
| 191 | humblenet_p2p_register_alias( &command[7] ); |
| 192 | } else if (command == "/unalias") { |
| 193 | humblenet_p2p_unregister_alias( nullptr ); |
| 194 | } else if (command.compare(0,9, "/unalias ") == 0) { |
| 195 | humblenet_p2p_unregister_alias( &command[9] ); |
| 196 | } else if (command.compare(0, 12, "/disconnect ") == 0) { |
| 197 | PeerId peer = strtoul(&command[12], NULL, 10); |
| 198 | if (peer != 0) { |
| 199 | disconnectPeer(peer); |
| 200 | } else { |
| 201 | disconnectPeer(humblenet_p2p_virtual_peer_for_alias( &command[12] ) ); |
| 202 | } |
| 203 | } else if (command.compare(0,1, "/" )== 0 ) { |
| 204 | std::cout << "Unknown command: " << command << std::endl; |
| 205 | } else { |
| 206 | sendChat(buffer); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | #endif |
| 211 | |
| 212 | static time_t last = 0; |
nothing calls this directly
no test coverage detected