client/Idle: move code to WriteIdleResponse()

This commit is contained in:
Max Kellermann 2018-01-20 00:18:53 +01:00
parent d096f75fb8
commit db89e5ec28
1 changed files with 14 additions and 8 deletions

View File

@ -23,6 +23,19 @@
#include <assert.h>
static void
WriteIdleResponse(Client &client, unsigned flags) noexcept
{
const char *const*idle_names = idle_get_names();
for (unsigned i = 0; idle_names[i]; ++i) {
if (flags & (1 << i))
client_printf(client, "changed: %s\n",
idle_names[i]);
}
client.Write("OK\n");
}
void
Client::IdleNotify() noexcept
{
@ -32,14 +45,7 @@ Client::IdleNotify() noexcept
unsigned flags = std::exchange(idle_flags, 0) & idle_subscriptions;
idle_waiting = false;
const char *const*idle_names = idle_get_names();
for (unsigned i = 0; idle_names[i]; ++i) {
if (flags & (1 << i))
client_printf(*this, "changed: %s\n",
idle_names[i]);
}
Write("OK\n");
WriteIdleResponse(*this, flags);
timeout_event.Schedule(client_timeout);
}