MCPcopy Create free account
hub / github.com/axmolengine/axmol / performCommand

Method performCommand

core/base/Console.cpp:779–806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

777}
778
779void Console::performCommand(socket_native_type fd, std::string_view command)
780{
781 std::vector<std::string> args = Console::Utility::split(command, ' ');
782 if (args.empty())
783 {
784 throw std::runtime_error("Unknown command. Type 'help' for options\n");
785 }
786
787 auto it = _commands.find(Console::Utility::trim(args[0]));
788 if (it != _commands.end())
789 {
790 std::string args2;
791 for (size_t i = 1; i < args.size(); ++i)
792 {
793 if (i > 1)
794 {
795 args2 += ' ';
796 }
797 args2 += Console::Utility::trim(args[i]);
798 }
799 auto cmd = it->second;
800 cmd->commandGeneric(fd, args2);
801 }
802 else
803 {
804 throw std::runtime_error(std::string{"Unknown command "}.append(command).append(". Type 'help' for options\n"));
805 }
806}
807
808void Console::addClient()
809{

Callers

nothing calls this directly

Calls 7

commandGenericMethod · 0.80
splitFunction · 0.70
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected