MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / runLoop

Method runLoop

src/bzadmin/BZAdminClient.cpp:500–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500void BZAdminClient::runLoop() {
501
502 sLink.sendVarRequest();
503 std::string cmd;
504 std::map<std::string, uint16_t>::iterator iter;
505 ServerCode what(NoMessage);
506 while (true) {
507 what = checkMessage();
508 if (what == Superkilled || what == CommError) {
509 break;
510 }
511 if (ui != NULL && ui->checkCommand(cmd)) {
512 if (cmd == "/quit") {
513 break;
514 }
515 else if (cmd.substr(0, 6) == "/show ") {
516 if ((iter = msgTypeMap.find(cmd.substr(6))) == msgTypeMap.end()) {
517 ui->outputMessage(std::string("--- ERROR: ") + cmd.substr(6) +
518 " is an unknown message type", Red);
519 }
520 else {
521 showMessageType(cmd.substr(6));
522 ui->outputMessage(std::string("--- Will now show messages of the ")
523 + "type " + cmd.substr(6), Yellow);
524 }
525 }
526 else if (cmd.substr(0, 6) == "/hide ") {
527 if ((iter = msgTypeMap.find(cmd.substr(6))) == msgTypeMap.end()) {
528 ui->outputMessage(std::string("--- ERROR: ") + cmd.substr(6) +
529 " is an unknown message type", Red);
530 }
531 else {
532 ignoreMessageType(cmd.substr(6));
533 ui->outputMessage(std::string("--- Will now hide messages of the ")
534 + "type " + cmd.substr(6), Yellow);
535 }
536 }
537 else if (cmd == "/list") {
538 outputServerList();
539 }
540 else if (cmd != "") {
541 sendMessage(cmd, ui->getTarget());
542 }
543 }
544 }
545
546 // why did we leave the loop?
547 switch (what) {
548 case Superkilled:
549 lastMessage.first = "--- ERROR: Server forced disconnect";
550 lastMessage.second = Red;
551 break;
552 case CommError:
553 lastMessage.first = "--- ERROR: Connection to server lost";
554 lastMessage.second = Red;
555 break;
556 default:
557 waitForServer();

Callers 1

mainFunction · 0.80

Calls 7

sendMessageFunction · 0.85
sendVarRequestMethod · 0.80
checkCommandMethod · 0.45
findMethod · 0.45
endMethod · 0.45
outputMessageMethod · 0.45
getTargetMethod · 0.45

Tested by

no test coverage detected