]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Trying again 2001/head
authorJordan Zucker <jordan.zucker@gmail.com>
Mon, 31 Mar 2025 00:23:40 +0000 (17:23 -0700)
committerJordan Zucker <jordan.zucker@gmail.com>
Mon, 31 Mar 2025 00:23:40 +0000 (17:23 -0700)
.gitignore
mqtt.c

index cca6a00547a77274b1512b464dc79856f56c71f5..e330542fc26b0b50ea3c8c1e21dde2ecdf4f1845 100644 (file)
@@ -54,3 +54,6 @@ classic
 
 # vscode
 .vscode
+
+# IntelliJ/JetBrains
+.idea/
diff --git a/mqtt.c b/mqtt.c
index 07a2abb6afacc91d618e99acf9b11c1f79de417d..fcfb8666a5ec5d8fe75a75eff4110e062edae4ba 100644 (file)
--- 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++;