MCPcopy Create free account
hub / github.com/crownengine/crown / message_command

Function message_command

src/device/console_server.cpp:117–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 }
116
117 static void message_command(ConsoleServer &cs, u32 client_id, const char *json, void *user_data)
118 {
119 TempAllocator4096 ta;
120 JsonObject obj(ta);
121 JsonArray args(ta);
122
123 sjson::parse(obj, json);
124 sjson::parse_array(args, obj["args"]);
125
126 DynamicString command_name(ta);
127 sjson::parse_string(command_name, args[0]);
128
129 ConsoleServer::CommandData cmd;
130 cmd.command_function = NULL;
131 cmd.user_data = NULL;
132 cmd = hash_map::get(cs._commands, command_name.to_string_id(), cmd);
133
134 if (cmd.command_function == NULL) {
135 ((ConsoleServer *)user_data)->error(client_id, "Command not found");
136 return;
137 }
138
139 cmd.command_function(cs, client_id, args, cmd.user_data);
140 }
141
142 static void command_help(ConsoleServer &cs, u32 client_id, const JsonArray &args, void * /*user_data*/)
143 {

Callers

nothing calls this directly

Calls 5

getFunction · 0.85
parseFunction · 0.50
parse_arrayFunction · 0.50
parse_stringFunction · 0.50
errorMethod · 0.45

Tested by

no test coverage detected