Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
i_session.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2024, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
11#pragma once
12
21#include <cstdint>
22#include <string_view>
23#include <vector>
24
26
28{
29
49 {
50 public:
54 virtual ~i_session() = default;
55
56 // Non-copyable, non-movable (typically shared via shared_ptr)
57 i_session(const i_session&) = delete;
58 i_session& operator=(const i_session&) = delete;
59 i_session(i_session&&) = delete;
61
69 [[nodiscard]] virtual auto id() const -> std::string_view = 0;
70
75 [[nodiscard]] virtual auto is_connected() const -> bool = 0;
76
89 [[nodiscard]] virtual auto send(std::vector<uint8_t>&& data) -> VoidResult = 0;
90
97 virtual auto close() -> void = 0;
98
99 protected:
101 i_session() = default;
102 };
103
104} // namespace kcenon::network::interfaces
Interface for a single client session on the server side.
Definition i_session.h:49
virtual auto close() -> void=0
Closes the session.
i_session & operator=(const i_session &)=delete
virtual ~i_session()=default
Virtual destructor for proper cleanup.
i_session(const i_session &)=delete
virtual auto send(std::vector< uint8_t > &&data) -> VoidResult=0
Sends data to the client.
virtual auto is_connected() const -> bool=0
Checks if the session is currently connected.
virtual auto id() const -> std::string_view=0
Gets the unique identifier for this session.
i_session & operator=(i_session &&)=delete
Public header for Result<T> error handling types.