Abstract base for network endpoints (clients/servers).
More...
#include <endpoint.hxx>
|
| | Endpoint (const DeserializePacketFunction &deserialize_packet_function, std::shared_ptr< Logger::Log > logger) noexcept |
| | Constructs an Endpoint.
|
| |
| | Endpoint (const Endpoint &other)=delete |
| | Copy constructor (deleted).
|
| |
| | Endpoint (Endpoint &&other) noexcept=default |
| | Move constructor.
|
| |
| virtual | ~Endpoint () noexcept=default |
| | Virtual destructor.
|
| |
| Endpoint & | operator= (const Endpoint &other)=delete |
| | Copy-assignment operator (deleted).
|
| |
| Endpoint & | operator= (Endpoint &&other) noexcept=default |
| | Move-assignment operator.
|
| |
| virtual bool | Connect (const Connection::Protocol &protocol, const std::string &address, const unsigned short &port)=0 |
| | Establish a connection to a server.
|
| |
| virtual void | Disconnect () noexcept=0 |
| | Disconnect from the server, if connected.
|
| |
| virtual Connection::Status | Status () const noexcept=0 |
| | Gets the current connection status.
|
| |
|
| std::shared_ptr< Connection::Client > | CreateConnection (std::shared_ptr< Socket::Client > socket) noexcept |
| | Create a Connection::Client wrapper for an accepted socket.
|
| |
| virtual Buffer::Pipeline | InputPipeline () const noexcept=0 |
| | Provide the input Buffer::Pipeline for incoming data.
|
| |
| virtual Buffer::Pipeline | OutputPipeline () const noexcept=0 |
| | Provide the output Buffer::Pipeline for outgoing data.
|
| |
| PacketPointer | Send (std::shared_ptr< Connection::Client > client_connection, const Transport::Packet &packet) noexcept |
| | Send a transport packet over the specified connection and obtains the response.
|
| |
| bool | Reply (std::shared_ptr< Connection::Client > client_connection, const Transport::Packet &packet) noexcept |
| | Send a transport packet as a reply over the specified connection.
|
| |
|
|
DeserializePacketFunction | m_deserialize_packet_function |
| | The packet deserialization function.
|
| |
|
std::shared_ptr< Logger::Log > | m_logger |
| | The logger instance.
|
| |
Abstract base for network endpoints (clients/servers).
Provides common functionality shared by concrete endpoint implementations such as Client and Server. This class is exported from the library but is not intended to be instantiated directly; implementors should derive from Endpoint and override the protected hooks as required.
◆ Endpoint() [1/3]
| StormByte::Network::Endpoint::Endpoint |
( |
const DeserializePacketFunction & |
deserialize_packet_function, |
|
|
std::shared_ptr< Logger::Log > |
logger |
|
) |
| |
|
noexcept |
Constructs an Endpoint.
- Parameters
-
| deserialize_packet_function | Function used to deserialize incoming transport packets into domain Packet objects. |
| logger | Logger instance used by the endpoint for diagnostic messages (copied into the endpoint). |
◆ Endpoint() [2/3]
| StormByte::Network::Endpoint::Endpoint |
( |
const Endpoint & |
other | ) |
|
|
delete |
Copy constructor (deleted).
Copying is disabled to avoid accidental sharing of connection state.
◆ Endpoint() [3/3]
| StormByte::Network::Endpoint::Endpoint |
( |
Endpoint && |
other | ) |
|
|
defaultnoexcept |
Move constructor.
Move semantics are supported to allow transfer of ownership of non-copyable members.
◆ ~Endpoint()
| virtual StormByte::Network::Endpoint::~Endpoint |
( |
| ) |
|
|
virtualdefaultnoexcept |
Virtual destructor.
Declared pure to make Endpoint an abstract base. Concrete subclasses must provide an implementation for the destructor (even if defaulted) in their translation unit.
◆ Connect()
| virtual bool StormByte::Network::Endpoint::Connect |
( |
const Connection::Protocol & |
protocol, |
|
|
const std::string & |
address, |
|
|
const unsigned short & |
port |
|
) |
| |
|
pure virtual |
Establish a connection to a server.
- Parameters
-
| protocol | The protocol to use for the connection. |
| port | The port to connect to. |
- Returns
- True if the connection was successful, false otherwise.
Implemented in StormByte::Network::Client, and StormByte::Network::Server.
◆ CreateConnection()
| std::shared_ptr< Connection::Client > StormByte::Network::Endpoint::CreateConnection |
( |
std::shared_ptr< Socket::Client > |
socket | ) |
|
|
protectednoexcept |
Create a Connection::Client wrapper for an accepted socket.
- Parameters
-
| socket | Shared pointer to the underlying client socket. |
- Returns
- Shared pointer to the created
Connection::Client instance.
◆ Disconnect()
| virtual void StormByte::Network::Endpoint::Disconnect |
( |
| ) |
|
|
pure virtualnoexcept |
◆ InputPipeline()
| virtual Buffer::Pipeline StormByte::Network::Endpoint::InputPipeline |
( |
| ) |
const |
|
protectedpure virtualnoexcept |
Provide the input Buffer::Pipeline for incoming data.
Override this hook in derived classes to return a custom pipeline that will be applied to inbound buffers.
- Returns
- A
Buffer::Pipeline instance for input processing.
◆ operator=() [1/2]
Copy-assignment operator (deleted).
Copy assignment is disabled for the same reasons as copy construction.
◆ operator=() [2/2]
Move-assignment operator.
Provides move-assignment for transfer of ownership of internal resources.
◆ OutputPipeline()
| virtual Buffer::Pipeline StormByte::Network::Endpoint::OutputPipeline |
( |
| ) |
const |
|
protectedpure virtualnoexcept |
Provide the output Buffer::Pipeline for outgoing data.
Override this hook to return a pipeline that will be applied to buffers before they are transmitted.
- Returns
- A
Buffer::Pipeline instance for output processing.
◆ Reply()
| bool StormByte::Network::Endpoint::Reply |
( |
std::shared_ptr< Connection::Client > |
client_connection, |
|
|
const Transport::Packet & |
packet |
|
) |
| |
|
protectednoexcept |
Send a transport packet as a reply over the specified connection.
The packet is prepared (e.g. serialized/enqueued) and handed to the transport for transmission. This function does not expect a response packet.
- Parameters
-
| client_connection | Connection to use for sending the packet. |
| packet | The transport-level packet to send. |
- Returns
- True if the packet was sent successfully, false otherwise.
◆ Send()
Send a transport packet over the specified connection and obtains the response.
The packet is prepared (e.g. serialized/enqueued) and handed to the transport for transmission. Implementations should return a pointer to the packet representation used by the transport, or nullptr on failure.
- Parameters
-
| client_connection | Connection to use for sending the packet. |
| packet | The transport-level packet to send. |
- Returns
- A
PacketPointer to the enqueued/sent packet, or nullptr if sending failed.
◆ Status()
| virtual Connection::Status StormByte::Network::Endpoint::Status |
( |
| ) |
const |
|
pure virtualnoexcept |
The documentation for this class was generated from the following file:
- /home/runner/work/StormByte-Network/StormByte-Network/lib/public/StormByte/network/endpoint.hxx