1
0
forked from blue/pica
pica/server/session.h

40 lines
951 B
C++

//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <string>
#include "request/accepting.h"
#include "taskmanager/scheduler.h"
class Session : public Accepting {
public:
Session(
std::weak_ptr<TM::Scheduler> scheduler,
unsigned int id,
const std::string& access,
const std::string& renew
);
Session(const Session&) = delete;
Session(Session&& other);
~Session();
Session& operator = (const Session&) = delete;
Session& operator = (Session&& other);
std::string getAccessToken() const;
std::string getRenewToken() const;
void accept(std::unique_ptr<Request> request) override;
private:
void onTimeout();
private:
std::weak_ptr<TM::Scheduler> scheduler;
unsigned int id;
std::string access;
std::string renew;
std::unique_ptr<Request> polling;
TM::Record::ID timeoutId;
};