mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-28 11:50:26 +00:00
fix: better error handling for unknown requests
This commit is contained in:
parent
413ba3340e
commit
298d7844e2
@ -71,12 +71,15 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
if (je == 1)
|
if (je == 1)
|
||||||
cmd_id = get_cmd_id(cmd);
|
cmd_id = get_cmd_id(cmd);
|
||||||
else
|
else
|
||||||
return;
|
cmd_id = get_cmd_id("MPD_API_UNKNOWN");
|
||||||
|
|
||||||
if(cmd_id == -1)
|
if(cmd_id == -1)
|
||||||
return;
|
cmd_id = get_cmd_id("MPD_API_UNKNOWN");
|
||||||
|
|
||||||
switch(cmd_id) {
|
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:
|
case MPD_API_SET_SETTINGS:
|
||||||
json_scanf(msg.p, msg.len, "{ data: { notificationWeb: %d, notificationPage: %d} }", &state.a, &state.b);
|
json_scanf(msg.p, msg.len, "{ data: { notificationWeb: %d, notificationPage: %d} }", &state.a, &state.b);
|
||||||
char tmpfile[200];
|
char tmpfile[200];
|
||||||
|
@ -83,7 +83,8 @@
|
|||||||
X(MPD_API_GET_SONGDETAILS) \
|
X(MPD_API_GET_SONGDETAILS) \
|
||||||
X(MPD_API_WELCOME) \
|
X(MPD_API_WELCOME) \
|
||||||
X(MPD_API_GET_SETTINGS) \
|
X(MPD_API_GET_SETTINGS) \
|
||||||
X(MPD_API_SET_SETTINGS)
|
X(MPD_API_SET_SETTINGS) \
|
||||||
|
X(MPD_API_UNKNOWN)
|
||||||
|
|
||||||
enum mpd_cmd_ids {
|
enum mpd_cmd_ids {
|
||||||
MPD_CMDS(GEN_ENUM)
|
MPD_CMDS(GEN_ENUM)
|
||||||
|
Loading…
Reference in New Issue
Block a user