diff options
author | Max Kellermann <max@duempel.org> | 2008-10-14 22:38:14 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-14 22:38:14 +0200 |
commit | a3e3d2c9506d17b3e19e205535ec263ee75178c9 (patch) | |
tree | 3e93ea6ae33dba8a8f5e12e34629366dcdd7fdb7 /src/command.c | |
parent | 30c86d8ae64ae46ba3bcb1c63e867789feab6dc4 (diff) | |
download | mpd-a3e3d2c9506d17b3e19e205535ec263ee75178c9.tar.gz mpd-a3e3d2c9506d17b3e19e205535ec263ee75178c9.tar.xz mpd-a3e3d2c9506d17b3e19e205535ec263ee75178c9.zip |
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.
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 12 |
1 files changed, 12 insertions, 0 deletions
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); } |