Represents a network endpoint, serving as a base class for both clients and servers.
More...
#include <endpoint.hxx>
|
| EndPoint (const Connection::Protocol &protocol, std::shared_ptr< Connection::Handler > handler, std::shared_ptr< Logger > logger) noexcept |
| Constructs an EndPoint with the specified protocol, handler, and logger.
|
|
| EndPoint (const EndPoint &other)=delete |
| Deleted copy constructor to prevent copying.
|
|
| EndPoint (EndPoint &&other) noexcept=default |
| Defaulted move constructor.
|
|
virtual | ~EndPoint () noexcept |
| Virtual destructor for proper cleanup in derived classes.
|
|
EndPoint & | operator= (const EndPoint &other)=delete |
| Deleted copy assignment operator to prevent copying.
|
|
EndPoint & | operator= (EndPoint &&other) noexcept=default |
| Defaulted move assignment operator.
|
|
virtual ExpectedVoid | Connect (const std::string &host, const unsigned short &port) noexcept=0 |
| Starts the endpoint (client or server) and connects/binds to the specified host and port.
|
|
virtual void | Disconnect () noexcept |
| Stops the endpoint (client or server) and disconnects.
|
|
const Connection::Protocol & | Protocol () const noexcept |
| Retrieves the protocol used by the endpoint.
|
|
Connection::Status | Status () const noexcept |
| Retrieves the current connection status of the endpoint.
|
|
|
virtual ExpectedVoid | Handshake (Socket::Client &client) noexcept |
| Sets up the connection handler for the endpoint.
|
|
virtual ExpectedVoid | Authenticate (Socket::Client &client) noexcept |
| Authenticates the client connection.
|
|
ExpectedPacket | Receive (Socket::Client &client) noexcept |
| Receives packet from the client processing pipeline before constructing packet.
|
|
ExpectedPacket | RawReceive (Socket::Client &client) noexcept |
| Receives packet from the client without processing pipeline before constructing packet.
|
|
ExpectedVoid | Send (Socket::Client &client, const Packet &packet) noexcept |
| Sends a packet to the client processing pipeline before sending packet.
|
|
ExpectedVoid | RawSend (Socket::Client &client, const Packet &packet) noexcept |
| Sends a packet to the client without processing pipeline before sending packet.
|
|
|
Connection::Protocol | m_protocol |
| The protocol used by the endpoint (e.g., IPv4, IPv6).
|
|
std::shared_ptr< Connection::Handler > | m_handler |
| Shared pointer to the connection handler.
|
|
std::shared_ptr< Logger > | m_logger |
| Shared pointer to the logger instance.
|
|
std::atomic< Connection::Status > | m_status |
| The current connection status of the endpoint.
|
|
Socket::Socket * | m_socket |
| Unique pointer to the socket instance.
|
|
Buffer::Pipeline | m_input_pipeline |
|
Buffer::Pipeline | m_output_pipeline |
| The input/output pipeline for processing data.
|
|
Represents a network endpoint, serving as a base class for both clients and servers.
◆ EndPoint()
StormByte::Network::EndPoint::EndPoint |
( |
const Connection::Protocol & |
protocol, |
|
|
std::shared_ptr< Connection::Handler > |
handler, |
|
|
std::shared_ptr< Logger > |
logger |
|
) |
| |
|
noexcept |
Constructs an EndPoint with the specified protocol, handler, and logger.
- Parameters
-
protocol | The protocol to use (e.g., IPv4, IPv6). |
handler | A shared pointer to the connection handler. |
logger | A shared pointer to the logger instance. |
◆ Authenticate()
virtual ExpectedVoid StormByte::Network::EndPoint::Authenticate |
( |
Socket::Client & |
client | ) |
|
|
protectedvirtualnoexcept |
Authenticates the client connection.
- Parameters
-
client | A reference to the client socket. |
- Returns
- An expected void or error.
◆ Connect()
virtual ExpectedVoid StormByte::Network::EndPoint::Connect |
( |
const std::string & |
host, |
|
|
const unsigned short & |
port |
|
) |
| |
|
pure virtualnoexcept |
Starts the endpoint (client or server) and connects/binds to the specified host and port.
- Parameters
-
host | The hostname or IP address to connect to. |
port | The port number to connect to. |
- Returns
- An expected void or error.
Implemented in StormByte::Network::Server, and StormByte::Network::Client.
◆ Disconnect()
virtual void StormByte::Network::EndPoint::Disconnect |
( |
| ) |
|
|
virtualnoexcept |
◆ Handshake()
virtual ExpectedVoid StormByte::Network::EndPoint::Handshake |
( |
Socket::Client & |
client | ) |
|
|
protectedvirtualnoexcept |
Sets up the connection handler for the endpoint.
- Parameters
-
client | A reference to the client socket. |
- Returns
- An expected void or error.
◆ Protocol()
const Connection::Protocol & StormByte::Network::EndPoint::Protocol |
( |
| ) |
const |
|
noexcept |
Retrieves the protocol used by the endpoint.
- Returns
- A constant reference to the protocol.
◆ RawReceive()
ExpectedPacket StormByte::Network::EndPoint::RawReceive |
( |
Socket::Client & |
client | ) |
|
|
protectednoexcept |
Receives packet from the client without processing pipeline before constructing packet.
- Parameters
-
client | A reference to the client socket. |
- Returns
- An expected packet or error.
◆ RawSend()
ExpectedVoid StormByte::Network::EndPoint::RawSend |
( |
Socket::Client & |
client, |
|
|
const Packet & |
packet |
|
) |
| |
|
protectednoexcept |
Sends a packet to the client without processing pipeline before sending packet.
- Parameters
-
client | A reference to the client socket. |
packet | The packet to send. |
- Returns
- An expected void or error.
◆ Receive()
ExpectedPacket StormByte::Network::EndPoint::Receive |
( |
Socket::Client & |
client | ) |
|
|
protectednoexcept |
Receives packet from the client processing pipeline before constructing packet.
- Parameters
-
client | A reference to the client socket. |
pif | The packet instance function to create a packet. |
- Returns
- An expected packet or error.
◆ Send()
ExpectedVoid StormByte::Network::EndPoint::Send |
( |
Socket::Client & |
client, |
|
|
const Packet & |
packet |
|
) |
| |
|
protectednoexcept |
Sends a packet to the client processing pipeline before sending packet.
- Parameters
-
client | A reference to the client socket. |
packet | The packet to send. |
- Returns
- An expected void or error.
◆ Status()
Connection::Status StormByte::Network::EndPoint::Status |
( |
| ) |
const |
|
noexcept |
Retrieves the current connection status of the endpoint.
- Returns
- The current connection status.
The documentation for this class was generated from the following file:
- /home/runner/work/StormByte-Network/StormByte-Network/lib/public/StormByte/network/endpoint.hxx