client/Idle: move code to WriteIdleResponse()
This commit is contained in:
@@ -23,6 +23,19 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#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
|
void
|
||||||
Client::IdleNotify() noexcept
|
Client::IdleNotify() noexcept
|
||||||
{
|
{
|
||||||
@@ -32,14 +45,7 @@ Client::IdleNotify() noexcept
|
|||||||
unsigned flags = std::exchange(idle_flags, 0) & idle_subscriptions;
|
unsigned flags = std::exchange(idle_flags, 0) & idle_subscriptions;
|
||||||
idle_waiting = false;
|
idle_waiting = false;
|
||||||
|
|
||||||
const char *const*idle_names = idle_get_names();
|
WriteIdleResponse(*this, flags);
|
||||||
for (unsigned i = 0; idle_names[i]; ++i) {
|
|
||||||
if (flags & (1 << i))
|
|
||||||
client_printf(*this, "changed: %s\n",
|
|
||||||
idle_names[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Write("OK\n");
|
|
||||||
|
|
||||||
timeout_event.Schedule(client_timeout);
|
timeout_event.Schedule(client_timeout);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user