2023-12-30 22:42:11 +00:00
|
|
|
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
|
|
//SPDX-License-Identifier: GPL-3.0-or-later
|
2023-12-23 20:23:38 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2023-12-28 20:26:08 +00:00
|
|
|
#include "request/accepting.h"
|
2024-01-03 01:11:56 +00:00
|
|
|
#include "taskmanager/scheduler.h"
|
2023-12-28 20:26:08 +00:00
|
|
|
|
|
|
|
class Session : public Accepting {
|
2023-12-23 20:23:38 +00:00
|
|
|
public:
|
2024-01-03 01:11:56 +00:00
|
|
|
Session(
|
|
|
|
std::weak_ptr<TM::Scheduler> scheduler,
|
|
|
|
unsigned int id,
|
|
|
|
const std::string& access,
|
|
|
|
const std::string& renew
|
|
|
|
);
|
2023-12-29 17:40:00 +00:00
|
|
|
Session(const Session&) = delete;
|
|
|
|
Session(Session&& other);
|
2024-01-03 22:20:01 +00:00
|
|
|
~Session();
|
2023-12-29 17:40:00 +00:00
|
|
|
Session& operator = (const Session&) = delete;
|
|
|
|
Session& operator = (Session&& other);
|
2023-12-23 20:23:38 +00:00
|
|
|
|
|
|
|
std::string getAccessToken() const;
|
|
|
|
std::string getRenewToken() const;
|
2023-12-28 20:26:08 +00:00
|
|
|
void accept(std::unique_ptr<Request> request) override;
|
2023-12-23 20:23:38 +00:00
|
|
|
|
|
|
|
private:
|
2024-01-03 01:11:56 +00:00
|
|
|
void onTimeout();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::weak_ptr<TM::Scheduler> scheduler;
|
2023-12-23 20:23:38 +00:00
|
|
|
unsigned int id;
|
|
|
|
std::string access;
|
|
|
|
std::string renew;
|
2023-12-28 20:26:08 +00:00
|
|
|
std::unique_ptr<Request> polling;
|
2024-01-03 22:20:01 +00:00
|
|
|
TM::Record::ID timeoutId;
|
2023-12-23 20:23:38 +00:00
|
|
|
};
|