MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / readInput

Function readInput

tests/test_peer.cpp:170–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170void 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
212static time_t last = 0;

Callers

nothing calls this directly

Calls 5

toLowerFunction · 0.85
disconnectPeerFunction · 0.85
connectToPeerFunction · 0.70
sendChatFunction · 0.70
compareMethod · 0.45

Tested by

no test coverage detected