|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Represents a single QUIC client session on the server side. More...
#include <quic_session.h>


Public Member Functions | |
| quic_session (std::shared_ptr< internal::quic_socket > socket, std::string_view session_id) | |
| Constructs a QUIC session with an existing socket. | |
| ~quic_session () noexcept | |
| Destructor; closes the session if still active. | |
| quic_session (const quic_session &)=delete | |
| quic_session & | operator= (const quic_session &)=delete |
| auto | session_id () const -> const std::string & |
| Get the unique session identifier. | |
| auto | remote_endpoint () const -> asio::ip::udp::endpoint |
| Get the remote endpoint address. | |
| auto | is_active () const noexcept -> bool |
| Check if the session is currently active. | |
| auto | send (std::string_view data) -> VoidResult |
| Send string data on the default stream. | |
| auto | close (uint64_t error_code) -> VoidResult |
| Close the session gracefully with error code. | |
| auto | stats () const -> core::quic_connection_stats |
| Get connection statistics. | |
| auto | set_receive_callback (std::function< void(const std::vector< uint8_t > &)> callback) -> void |
| Set callback for received data on the default stream. | |
| auto | set_stream_receive_callback (std::function< void(uint64_t, const std::vector< uint8_t > &, bool)> callback) -> void |
| Set callback for stream data reception. | |
| auto | set_close_callback (std::function< void()> callback) -> void |
| Set callback when session closes. | |
| auto | start_session () -> void |
| Start receiving data (called by server). | |
| auto | handle_packet (std::span< const uint8_t > data) -> void |
| Handle incoming packet (called by server). | |
| auto | matches_connection_id (const protocols::quic::connection_id &conn_id) const -> bool |
| Check if this session matches a connection ID. | |
| auto | id () const -> std::string_view override |
| Gets the unique session identifier (interface version). | |
| auto | is_connected () const -> bool override |
| Checks if the session is currently connected (interface version). | |
| auto | send (std::vector< uint8_t > &&data) -> VoidResult override |
| Sends data to the client (interface version). | |
| auto | close () -> void override |
| Closes the session (interface version). | |
| auto | create_stream () -> Result< uint64_t > override |
| Creates a new bidirectional stream (interface version). | |
| auto | create_unidirectional_stream () -> Result< uint64_t > override |
| Creates a new unidirectional stream (interface version). | |
| auto | send_on_stream (uint64_t stream_id, std::vector< uint8_t > &&data, bool fin=false) -> VoidResult override |
| Sends data on a specific stream (interface version). | |
| auto | close_stream (uint64_t stream_id) -> VoidResult override |
| Closes a stream (interface version). | |
Public Member Functions inherited from kcenon::network::interfaces::i_quic_session | |
Public Member Functions inherited from kcenon::network::interfaces::i_session | |
| virtual | ~i_session ()=default |
| Virtual destructor for proper cleanup. | |
| i_session (const i_session &)=delete | |
| i_session & | operator= (const i_session &)=delete |
| i_session (i_session &&)=delete | |
| i_session & | operator= (i_session &&)=delete |
Private Member Functions | |
| auto | on_stream_data (uint64_t stream_id, std::span< const uint8_t > data, bool fin) -> void |
| auto | on_error (std::error_code ec) -> void |
| auto | on_close (uint64_t error_code, const std::string &reason) -> void |
Private Attributes | |
| std::string | session_id_ |
| std::mutex | socket_mutex_ |
| std::shared_ptr< internal::quic_socket > | socket_ |
| std::atomic< bool > | is_active_ {true} |
| uint64_t | default_stream_id_ {0} |
| std::function< void(const std::vector< uint8_t > &)> | receive_callback_ |
| std::function< void(uint64_t, const std::vector< uint8_t > &, bool)> | stream_receive_callback_ |
| std::function< void()> | close_callback_ |
| std::mutex | callback_mutex_ |
Additional Inherited Members | |
Protected Member Functions inherited from kcenon::network::interfaces::i_session | |
| i_session ()=default | |
| Default constructor (only for derived classes) | |
Represents a single QUIC client session on the server side.
This class wraps a QUIC connection from a connected client, providing methods to send/receive data, manage streams, and handle session lifecycle.
Definition at line 69 of file quic_session.h.
| kcenon::network::session::quic_session::quic_session | ( | std::shared_ptr< internal::quic_socket > | socket, |
| std::string_view | session_id ) |
Constructs a QUIC session with an existing socket.
| socket | The QUIC socket for this session. |
| session_id | Unique identifier for this session. |
Definition at line 14 of file quic_session.cpp.
References NETWORK_LOG_DEBUG, and session_id_.
|
noexcept |
Destructor; closes the session if still active.
Definition at line 21 of file quic_session.cpp.
References close(), and is_active_.

|
delete |
|
inlineoverridevirtual |
Closes the session (interface version).
Implements i_session::close().
Implements kcenon::network::interfaces::i_session.
Definition at line 231 of file quic_session.h.
References close().
Referenced by close(), and ~quic_session().


|
nodiscard |
Close the session gracefully with error code.
| error_code | Application error code (0 for no error). |
Definition at line 170 of file quic_session.cpp.
References NETWORK_LOG_ERROR, NETWORK_LOG_INFO, and kcenon::network::ok().

|
nodiscardoverridevirtual |
Closes a stream (interface version).
| stream_id | The stream to close. |
Implements i_quic_session::close_stream().
Implements kcenon::network::interfaces::i_quic_session.
Definition at line 150 of file quic_session.cpp.
References kcenon::network::error_codes::network_system::connection_closed, and kcenon::network::error_void().

|
nodiscardoverridevirtual |
Creates a new bidirectional stream (interface version).
Implements i_quic_session::create_stream().
Implements kcenon::network::interfaces::i_quic_session.
Definition at line 110 of file quic_session.cpp.
References kcenon::network::error_codes::network_system::connection_closed, and kcenon::network::error.
|
nodiscardoverridevirtual |
Creates a new unidirectional stream (interface version).
Implements i_quic_session::create_unidirectional_stream().
Implements kcenon::network::interfaces::i_quic_session.
Definition at line 130 of file quic_session.cpp.
References kcenon::network::error_codes::network_system::connection_closed, and kcenon::network::error.
| auto kcenon::network::session::quic_session::handle_packet | ( | std::span< const uint8_t > | data | ) | -> void |
Handle incoming packet (called by server).
| data | Raw packet data. |
Definition at line 283 of file quic_session.cpp.
|
inlinenodiscardoverridevirtual |
Gets the unique session identifier (interface version).
Implements i_session::id().
Implements kcenon::network::interfaces::i_session.
Definition at line 203 of file quic_session.h.
References session_id_.
|
nodiscardnoexcept |
Check if the session is currently active.
Definition at line 52 of file quic_session.cpp.
References is_active_.
Referenced by is_connected().

|
inlinenodiscardoverridevirtual |
Checks if the session is currently connected (interface version).
Implements i_session::is_connected().
Implements kcenon::network::interfaces::i_session.
Definition at line 213 of file quic_session.h.
References is_active().

|
nodiscard |
Check if this session matches a connection ID.
| conn_id | Connection ID to match. |
Definition at line 295 of file quic_session.cpp.
|
private |
Definition at line 366 of file quic_session.cpp.
References NETWORK_LOG_ERROR, and NETWORK_LOG_INFO.
|
private |
Definition at line 356 of file quic_session.cpp.
References NETWORK_LOG_ERROR.
|
private |
Definition at line 307 of file quic_session.cpp.
References NETWORK_LOG_DEBUG, NETWORK_LOG_ERROR, and kcenon::network::metrics::metric_reporter::report_bytes_received().

|
delete |
|
nodiscard |
Get the remote endpoint address.
Definition at line 42 of file quic_session.cpp.
References socket_, and socket_mutex_.
|
nodiscard |
Send string data on the default stream.
| data | String to send. |
Definition at line 80 of file quic_session.cpp.
|
nodiscardoverridevirtual |
Sends data to the client (interface version).
| data | The data to send. |
Implements i_session::send().
Implements kcenon::network::interfaces::i_session.
Definition at line 57 of file quic_session.cpp.
References kcenon::network::error_codes::network_system::connection_closed, kcenon::network::error_void(), and kcenon::network::metrics::metric_reporter::report_bytes_sent().

|
nodiscardoverridevirtual |
Sends data on a specific stream (interface version).
| stream_id | The target stream ID. |
| data | The data to send. |
| fin | True if this is the final data on the stream. |
Implements i_quic_session::send_on_stream().
Implements kcenon::network::interfaces::i_quic_session.
Definition at line 86 of file quic_session.cpp.
References kcenon::network::error_codes::network_system::connection_closed, kcenon::network::error_void(), and kcenon::network::metrics::metric_reporter::report_bytes_sent().

|
nodiscard |
Get the unique session identifier.
Definition at line 37 of file quic_session.cpp.
References session_id_.
| auto kcenon::network::session::quic_session::set_close_callback | ( | std::function< void()> | callback | ) | -> void |
Set callback when session closes.
| callback | Function called on session close. |
Definition at line 230 of file quic_session.cpp.
| auto kcenon::network::session::quic_session::set_receive_callback | ( | std::function< void(const std::vector< uint8_t > &)> | callback | ) | -> void |
Set callback for received data on the default stream.
| callback | Function called when data is received. |
Definition at line 215 of file quic_session.cpp.
| auto kcenon::network::session::quic_session::set_stream_receive_callback | ( | std::function< void(uint64_t, const std::vector< uint8_t > &, bool)> | callback | ) | -> void |
Set callback for stream data reception.
| callback | Function with stream_id, data, and fin flag. |
Definition at line 222 of file quic_session.cpp.
| auto kcenon::network::session::quic_session::start_session | ( | ) | -> void |
Start receiving data (called by server).
Definition at line 236 of file quic_session.cpp.
References NETWORK_LOG_INFO.
|
nodiscard |
Get connection statistics.
Definition at line 209 of file quic_session.cpp.
|
mutableprivate |
Definition at line 307 of file quic_session.h.
|
private |
Definition at line 305 of file quic_session.h.
|
private |
Definition at line 299 of file quic_session.h.
|
private |
Definition at line 297 of file quic_session.h.
Referenced by is_active(), and ~quic_session().
|
private |
Definition at line 302 of file quic_session.h.
|
private |
Definition at line 292 of file quic_session.h.
Referenced by id(), quic_session(), and session_id().
|
private |
Definition at line 295 of file quic_session.h.
Referenced by remote_endpoint().
|
mutableprivate |
Definition at line 294 of file quic_session.h.
Referenced by remote_endpoint().
|
private |
Definition at line 304 of file quic_session.h.