26#ifndef QB_IO_ASYNC_TCP_SESSION_H
27#define QB_IO_ASYNC_TCP_SESSION_H
32namespace qb::io::async::tcp {
46template <
typename _Derived,
typename _Transport,
typename _Server =
void>
56 typename _Transport::transport_io_type;
58 using _Transport::out;
59 using _Transport::transport;
88 if constexpr (has_member_Protocol<_Derived>::value) {
89 if constexpr (!std::is_void_v<typename _Derived::Protocol>) {
91 static_cast<_Derived &
>(*
this));
124 id() const noexcept {
134 return server().session(
id());
151 return transport().peer_endpoint().port();
168template <
typename _Derived,
typename _Transport>
179 typename _Transport::transport_io_type;
180 using _Transport::in;
181 using _Transport::out;
182 using _Transport::transport;
194 if constexpr (has_member_Protocol<_Derived>::value) {
195 if constexpr (!std::is_void_v<typename _Derived::Protocol>) {
197 static_cast<_Derived &
>(*
this));
_Protocol * switch_protocol(_Args &&...args)
Switches to a new protocol for I/O processing, taking ownership.
Definition io.h:988
io()=default
Default constructor.
auto & publish(_Args &&...args) noexcept
Publishes data to the output buffer and ensures write readiness.
Definition io.h:1073
io< _Derived > base_io_t
Base I/O type.
Definition client.h:177
client() noexcept
< Import the publish method from the base class
Definition client.h:193
const uuid _uuid
Unique identifier for this client.
Definition client.h:175
~client()=default
Destructor.
typename _Transport::transport_io_type transport_io_type
Transport I/O type.
Definition client.h:178
client()=delete
Default constructor (deleted)
io< _Derived > base_io_t
Definition client.h:54
static constexpr const bool has_server
Definition client.h:68
_Server & server()
Definition client.h:106
_Server & _server
Definition client.h:64
client(_Server &server)
Constructor with server reference.
Definition client.h:85
const uuid _uuid
Definition client.h:63
~client()=default
Destructor.
auto port() const
Get the client's port.
Definition client.h:150
uuid const & id() const noexcept
Get the client's unique identifier.
Definition client.h:124
_Server & server() const
Get the associated server (const version)
Definition client.h:115
auto ip() const
Get the client's IP address.
Definition client.h:141
_Server IOServer
Definition client.h:67
typename transport::tcp::transport_io_type transport_io_type
Definition client.h:55
auto shared() const
Get the client as a shared pointer.
Definition client.h:133
io::tcp::socket & transport() noexcept
Definition stream.h:76
Core asynchronous I/O class templates for event-driven operations.
Universally Unique Identifier (UUID) support.
uuid generate_random_uuid()
Generates a random (version 4) UUID.
::uuids::uuid uuid
UUID type alias for the underlying implementation.
Definition uuid.h:40