qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::io::protocol::handshake< _IO_ > Class Template Reference

Protocol for handling the handshake of a new connection. More...

#include <handshake.h>

Inheritance diagram for qb::io::protocol::handshake< _IO_ >:
Collaboration diagram for qb::io::protocol::handshake< _IO_ >:

Public Types

using message = qb::io::async::event::handshake
 Type alias for the handshake event.

Public Member Functions

 handshake ()=delete
 Default constructor is deleted as an I/O component reference is required.
 handshake (_IO_ &io) noexcept
 Constructor with I/O reference.
std::size_t getMessageSize () noexcept final
 Checks if the handshake is done.
void onMessage (std::size_t) noexcept final
 Triggers the handshake event.
void reset () noexcept final
 Resets the protocol state.
Public Member Functions inherited from qb::io::async::IProtocol
virtual ~IProtocol ()=default
 Virtual destructor.
bool ok () const noexcept
 Checks if the protocol is in a valid operational state.
void not_ok () noexcept
 Marks the protocol as being in an invalid or non-operational state.
void set_should_flush (bool should_flush) noexcept
 Sets the flag indicating whether the protocol should flush the input buffer after processing a message.
bool should_flush () const noexcept
 Gets the flag indicating whether the protocol should flush the input buffer after processing a message.

Additional Inherited Members

Protected Member Functions inherited from qb::io::async::AProtocol< _IO_ >
 AProtocol ()=delete
 Default constructor is deleted to ensure an I/O component is always associated.
 AProtocol (_IO_ &io) noexcept
 Constructor that associates the protocol with an I/O component.
virtual ~AProtocol ()=default
 Virtual destructor.
Protected Attributes inherited from qb::io::async::AProtocol< _IO_ >
_IO_ & _io
 Reference to the I/O component instance that this protocol is associated with.

Detailed Description

template<typename _IO_>
class qb::io::protocol::handshake< _IO_ >

Protocol for handling the handshake of a new connection.

This template class implements the AProtocol interface specifically for handshake components (like qb::io::tcp::ssl::socket).

Member Typedef Documentation

◆ message

template<typename _IO_>
using qb::io::protocol::handshake< _IO_ >::message = qb::io::async::event::handshake

Type alias for the handshake event.

The type of message this protocol produces, which is the handshake event.

Constructor & Destructor Documentation

◆ handshake()

template<typename _IO_>
qb::io::protocol::handshake< _IO_ >::handshake ( _IO_ & io)
inlinenoexcept

Constructor with I/O reference.

Parameters
ioReference to the I/O component (e.g., an acceptor) that will use this protocol.

Member Function Documentation

◆ getMessageSize()

template<typename _IO_>
std::size_t qb::io::protocol::handshake< _IO_ >::getMessageSize ( )
inlinefinalvirtualnoexcept

Checks if the handshake is done.

This method determines if the handshake is done by checking if the handshake is done.

Returns
1 if the handshake is done, 0 otherwise. The return type std::size_t is used to conform to the AProtocol interface, but effectively it's a boolean check.

Implements qb::io::async::AProtocol< _IO_ >.

◆ onMessage()

template<typename _IO_>
void qb::io::protocol::handshake< _IO_ >::onMessage ( std::size_t )
inlinefinalvirtualnoexcept

Triggers the handshake event.

This method is called when getMessageSize() returns a non-zero value (i.e., an open socket was found). It then calls the I/O component's on() handler, passing the handshake event.

Parameters
sizeIgnored parameter (required by AProtocol interface, but its value is not used here as getMessageSize() for this protocol effectively returns a boolean status).

Implements qb::io::async::AProtocol< _IO_ >.

◆ reset()

template<typename _IO_>
void qb::io::protocol::handshake< _IO_ >::reset ( )
inlinefinalvirtualnoexcept

Resets the protocol state.

This protocol is stateless regarding message parsing (it only checks handshake status), so this method is a no-op.

Implements qb::io::async::AProtocol< _IO_ >.