aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/main/session_manager.hpp
blob: 66b8d6737b238aaa91edcf8202302fdd4526391a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com>
// This file is part of the "math-server" project.
// For details, see https://github.com/egor-tensin/math-server.
// Distributed under the MIT License.

#pragma once

#include <boost/asio.hpp>

#include <mutex>
#include <memory>
#include <unordered_set>

namespace math::server {

class Session;
using SessionPtr = std::shared_ptr<Session>;

class SessionManager {
public:
    SessionManager() = default;

    SessionPtr make_session(boost::asio::io_context&);

    void start(const SessionPtr&);
    void stop(const SessionPtr&);

    void stop_all();

private:
    std::mutex m_mtx;
    std::unordered_set<SessionPtr> m_sessions;
};

}