Send the names of the commands. */
| 570 | |
| 571 | /** Send the names of the commands. */ |
| 572 | NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames() |
| 573 | { |
| 574 | auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES); |
| 575 | |
| 576 | for (uint16_t i = 0; i < CMD_END; i++) { |
| 577 | std::string_view cmdname = GetCommandName(static_cast<Commands>(i)); |
| 578 | |
| 579 | /* Should COMPAT_MTU be exceeded, start a new packet |
| 580 | * (magic 5: 1 bool "more data" and one uint16_t "command id", one |
| 581 | * byte for string '\0' termination and 1 bool "no more data" */ |
| 582 | if (!p->CanWriteToPacket(cmdname.size() + 5)) { |
| 583 | p->Send_bool(false); |
| 584 | this->SendPacket(std::move(p)); |
| 585 | |
| 586 | p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES); |
| 587 | } |
| 588 | |
| 589 | p->Send_bool(true); |
| 590 | p->Send_uint16(i); |
| 591 | p->Send_string(cmdname); |
| 592 | } |
| 593 | |
| 594 | /* Marker to notify the end of the packet has been reached. */ |
| 595 | p->Send_bool(false); |
| 596 | this->SendPacket(std::move(p)); |
| 597 | |
| 598 | return NETWORK_RECV_STATUS_OKAY; |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Send a command for logging purposes. |
no test coverage detected