diff --git a/modules/client/sync.cc b/modules/client/sync.cc index 7de1aa676..b8e24c2cd 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -322,6 +322,7 @@ void longpoll_sync(client &client, const resource::request &request, const syncargs &args) +try { std::unique_lock lock { @@ -332,8 +333,7 @@ longpoll_sync(client &client, { auto &accepted { - //m::vm::accept.wait_for(lock, milliseconds(sync_timeout_min)) - m::vm::accept.wait(lock) + m::vm::accept.wait_until(lock, args.timesout) }; const unlock_guard ul(lock); @@ -341,6 +341,25 @@ longpoll_sync(client &client, return; } } +catch(const ctx::timeout &e) +{ + const ctx::exception_handler eh; + + const int64_t &since + { + int64_t(m::vm::current_sequence) + }; + + resource::response + { + client, json::members + { + { "next_batch", int64_t(since) }, + { "rooms", json::object{} }, + { "presence", json::object{} }, + } + }; +} static bool synchronize(client &client,