pica/server/session.cpp
2023-12-28 17:26:08 -03:00

34 lines
814 B
C++

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "session.h"
#include "handler/poll.h"
Session::Session(unsigned int id, const std::string& access, const std::string& renew):
id(id),
access(access),
renew(renew),
polling(nullptr)
{}
std::string Session::getAccessToken() const {
return access;
}
std::string Session::getRenewToken() const {
return renew;
}
void Session::accept(std::unique_ptr<Request> request) {
if (polling) {
Response& res = request->createResponse(Response::Status::ok);
nlohmann::json body = nlohmann::json::object();
body["result"] = Handler::Poll::Result::replace;
res.setBody(body);
res.send();
}
polling = std::move(request);
}