From a3e3d2c9506d17b3e19e205535ec263ee75178c9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 14 Oct 2008 22:38:14 +0200 Subject: 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. --- src/command.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 14ba2c300..1037c812d 100644 --- a/src/command.c +++ b/src/command.c @@ -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); } -- cgit v1.2.3