command: added command "idle"

"idle" waits until something noteworthy happens on the server,
e.g. song change, playlist modified, database updated.  This allows
clients to keep up to date without polling.
This commit is contained in:
Max Kellermann
2008-10-14 22:38:14 +02:00
parent 30c86d8ae6
commit a3e3d2c950
14 changed files with 305 additions and 3 deletions

View File

@@ -1239,6 +1239,17 @@ static int handlePlaylistAdd(struct client *client,
return print_playlist_result(client, result);
}
static int
handle_idle(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{
/* enable "idle" mode on this client */
client_idle_wait(client);
/* return value is "1" so the caller won't print "OK" */
return 1;
}
void initCommands(void)
{
commandList = makeList(free, 1);
@@ -1307,6 +1318,7 @@ void initCommands(void)
addCommand(COMMAND_TAGTYPES, PERMISSION_READ, 0, 0, handleTagTypes);
addCommand(COMMAND_COUNT, PERMISSION_READ, 2, -1, handleCount);
addCommand(COMMAND_RENAME, PERMISSION_CONTROL, 2, 2, handleRename);
addCommand("idle", PERMISSION_READ, 0, 0, handle_idle);
sortList(commandList);
}