From da4cb008167eeb182d340aa1d8fafee83e8067c3 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Sun, 30 Mar 2025 17:23:40 -0700 Subject: [PATCH] Trying again --- .gitignore | 3 +++ mqtt.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cca6a005..e330542f 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ classic # vscode .vscode + +# IntelliJ/JetBrains +.idea/ diff --git a/mqtt.c b/mqtt.c index 07a2abb6..fcfb8666 100644 --- a/mqtt.c +++ b/mqtt.c @@ -56,7 +56,8 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq, // All recognized commands char *commands[] = {"command", "beginff", "beginrew", "mutetoggle", "nextitem", "previtem", "pause", "playpause", "play", "stop", - "playresume", "shuffle_songs", "volumedown", "volumeup", NULL}; + "playresume", "shuffle_songs", "volumedown", "volumeup", "disconnect", + NULL}; int it = 0; @@ -64,8 +65,14 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq, while (commands[it] != NULL) { if ((size_t)msg->payloadlen >= strlen(commands[it]) && strncmp(msg->payload, commands[it], strlen(commands[it])) == 0) { - debug(2, "[MQTT]: DACP Command: %s\n", commands[it]); - send_simple_dacp_command(commands[it]); + debug(2, "[MQTT]: Received Recognized Command: %s\n", commands[it]); + if (strcmp(commands[it], "disconnect") == 0) { + debug(2, "[MQTT]: Disconnect Command: %s\n", commands[it]); + get_play_lock(NULL, 1); // stop any current session and don't replace it + } else { + debug(2, "[MQTT]: DACP Command: %s\n", commands[it]); + send_simple_dacp_command(commands[it]); + } break; } it++; -- 2.47.2