1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-27 03:10:26 +00:00

fix: better error handling for unknown requests

This commit is contained in:
jcorporation 2018-07-19 18:58:23 +01:00
parent 413ba3340e
commit 298d7844e2
2 changed files with 8 additions and 4 deletions

View File

@ -69,14 +69,17 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
je = json_scanf(msg.p, msg.len, "{cmd:%Q}", &cmd);
if (je == 1)
cmd_id = get_cmd_id(cmd);
cmd_id = get_cmd_id(cmd);
else
return;
cmd_id = get_cmd_id("MPD_API_UNKNOWN");
if(cmd_id == -1)
return;
cmd_id = get_cmd_id("MPD_API_UNKNOWN");
switch(cmd_id) {
case MPD_API_UNKNOWN:
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"error\", \"data\": \"Unknown request: %.*s\"}", msg.len, msg.p );
break;
case MPD_API_SET_SETTINGS:
json_scanf(msg.p, msg.len, "{ data: { notificationWeb: %d, notificationPage: %d} }", &state.a, &state.b);
char tmpfile[200];

View File

@ -83,7 +83,8 @@
X(MPD_API_GET_SONGDETAILS) \
X(MPD_API_WELCOME) \
X(MPD_API_GET_SETTINGS) \
X(MPD_API_SET_SETTINGS)
X(MPD_API_SET_SETTINGS) \
X(MPD_API_UNKNOWN)
enum mpd_cmd_ids {
MPD_CMDS(GEN_ENUM)