bool revive_if_needed(std::unique_lock<std::mutex>& lock, SyncSession& session) const override { // Revive. session.create_sync_session(); session.advance_state(lock, waiting_for_access_token); return true; }
void bind_with_admin_token(std::unique_lock<std::mutex>& lock, SyncSession& session, const std::string& admin_token, const std::string& server_url) const override { session.create_sync_session(); session.advance_state(lock, waiting_for_access_token); session.m_state->refresh_access_token(lock, session, admin_token, server_url); }
void refresh_access_token(std::unique_lock<std::mutex>& lock, SyncSession& session, std::string access_token, const util::Optional<std::string>& server_url) const override { session.create_sync_session(); // Since the sync session was previously unbound, it's safe to do this from the // calling thread. if (!session.m_server_url) { session.m_server_url = server_url; } if (session.m_session_has_been_bound) { session.m_session->refresh(std::move(access_token)); session.m_session->cancel_reconnect_delay(); } else { session.m_session->bind(*session.m_server_url, std::move(access_token)); session.m_session_has_been_bound = true; } if (session.m_server_override) session.m_session->override_server(session.m_server_override->address, session.m_server_override->port); // Register all the pending wait-for-completion blocks. for (auto& package : session.m_completion_wait_packages) { (*session.m_session.*package.waiter)(std::move(package.callback)); } session.m_completion_wait_packages.clear(); // Handle any deferred commit notification. if (session.m_deferred_commit_notification) { session.m_session->nonsync_transact_notify(*session.m_deferred_commit_notification); session.m_deferred_commit_notification = util::none; } session.advance_state(lock, active); if (session.m_deferred_close) { session.m_state->close(lock, session); } }