StormByte-Network 4.0.0
C++26 networking module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Network::Endpoint Class Referenceabstract

Shared base for Client and Server. More...

#include <StormByte/network/endpoint.hxx>

Inheritance diagram for StormByte::Network::Endpoint:
Collaboration diagram for StormByte::Network::Endpoint:

Public Member Functions

 Endpoint (DeserializePacketFunction deserialize_packet_function, StormByte::Safe::Shared< Logger::Log > logger) noexcept
 Construct with a packet factory and a logger.
 Endpoint (const Endpoint &other)=delete
 Copy constructor (deleted).
 Endpoint (Endpoint &&other) noexcept
 Move constructor.
virtual ~Endpoint () noexcept
 Destructor.
Endpoint & operator= (const Endpoint &other)=delete
 Copy assignment (deleted).
Endpoint & operator= (Endpoint &&other) noexcept
 Move assignment.
virtual bool Connect (const Connection::Protocol &protocol, std::string_view address, const unsigned short &port)=0
 Connect or listen (meaning depends on the derived class).
virtual void Disconnect () noexcept=0
 Tear down the endpoint.
virtual Connection::Status Status () const noexcept=0
 Current connection/listen status.

Protected Member Functions

StormByte::Safe::Shared< Connection::Client > CreateConnection (StormByte::Safe::Shared< Socket::Client > socket) noexcept
 Wrap a socket client with initially empty input/output pipelines.
PacketPointer Send (StormByte::Safe::Shared< Connection::Client > client_connection, const Transport::Packet &packet) noexcept
 Send packet and wait for a response frame.
bool Reply (StormByte::Safe::Shared< Connection::Client > client_connection, const Transport::Packet &packet) noexcept
 Send packet without waiting for a reply.

Protected Attributes

DeserializePacketFunction m_deserialize_packet_function
 Packet factory used to deserialize received wire data.
StormByte::Safe::Shared< Logger::Log > m_logger
 Shared diagnostic logger for this endpoint.

Detailed Description

Shared base for Client and Server.

Not instantiated directly. Connections start with no-op pipelines. Derived Client and Server types configure individual connections explicitly. Use Send() / Reply() for framed request/response.

Note
Inheritance-oriented. Derive from Client / Server, not from Endpoint alone.

Constructor & Destructor Documentation

◆ Endpoint() [1/3]

StormByte::Network::Endpoint::Endpoint ( DeserializePacketFunction deserialize_packet_function,
StormByte::Safe::Shared< Logger::Log > logger )
noexcept

Construct with a packet factory and a logger.

Parameters
deserialize_packet_functionBuilds domain packets from wire data.
loggerDiagnostic logger.

◆ Endpoint() [2/3]

StormByte::Network::Endpoint::Endpoint ( const Endpoint & other)
delete

Copy constructor (deleted).

Parameters
otherEndpoint that cannot be copied.

◆ Endpoint() [3/3]

StormByte::Network::Endpoint::Endpoint ( Endpoint && other)
noexcept

Move constructor.

Parameters
otherEndpoint whose state is transferred.

◆ ~Endpoint()

virtual StormByte::Network::Endpoint::~Endpoint ( )
virtualnoexcept

Destructor.

Member Function Documentation

◆ Connect()

virtual bool StormByte::Network::Endpoint::Connect ( const Connection::Protocol & protocol,
std::string_view address,
const unsigned short & port )
pure virtual

Connect or listen (meaning depends on the derived class).

Parameters
protocolAddress family.
addressHost or bind address.
portPort number.
Returns
true on success.

Implemented in StormByte::Network::Client, and StormByte::Network::Server.

◆ CreateConnection()

StormByte::Safe::Shared< Connection::Client > StormByte::Network::Endpoint::CreateConnection ( StormByte::Safe::Shared< Socket::Client > socket)
protectednoexcept

Wrap a socket client with initially empty input/output pipelines.

Parameters
socketUnderlying socket client.
Returns
Connection::Client.

◆ Disconnect()

virtual void StormByte::Network::Endpoint::Disconnect ( )
pure virtualnoexcept

Tear down the endpoint.

Implemented in StormByte::Network::Client, and StormByte::Network::Server.

◆ operator=() [1/2]

Endpoint & StormByte::Network::Endpoint::operator= ( const Endpoint & other)
delete

Copy assignment (deleted).

Parameters
otherEndpoint that cannot be copied.
Returns
Reference to this endpoint (operation is deleted).

◆ operator=() [2/2]

Endpoint & StormByte::Network::Endpoint::operator= ( Endpoint && other)
noexcept

Move assignment.

Parameters
otherEndpoint whose state is transferred.
Returns
Reference to this endpoint.

◆ Reply()

bool StormByte::Network::Endpoint::Reply ( StormByte::Safe::Shared< Connection::Client > client_connection,
const Transport::Packet & packet )
protectednoexcept

Send packet without waiting for a reply.

Parameters
client_connectionActive connection.
packetPacket to send.
Returns
true on success.

◆ Send()

PacketPointer StormByte::Network::Endpoint::Send ( StormByte::Safe::Shared< Connection::Client > client_connection,
const Transport::Packet & packet )
protectednoexcept

Send packet and wait for a response frame.

Parameters
client_connectionActive connection.
packetPacket to send.
Returns
Response packet, or nullptr on failure.

◆ Status()

virtual Connection::Status StormByte::Network::Endpoint::Status ( ) const
pure virtualnoexcept

Current connection/listen status.

Returns
Status.

Implemented in StormByte::Network::Client, and StormByte::Network::Server.

Member Data Documentation

◆ m_deserialize_packet_function

DeserializePacketFunction StormByte::Network::Endpoint::m_deserialize_packet_function
protected

Packet factory used to deserialize received wire data.

◆ m_logger

StormByte::Safe::Shared<Logger::Log> StormByte::Network::Endpoint::m_logger
protected

Shared diagnostic logger for this endpoint.


The documentation for this class was generated from the following file: