StormByte C++ Library: Network module 1.1.0
StormByte-Network is the C++26 networking module of the StormByte suite.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
StormByte::Network::Endpoint Class Referenceabstract

Shared base for Client and Server. More...

#include <StormByte/network/endpoint.hxx>

Inheritance diagram for StormByte::Network::Endpoint:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Network::Endpoint:
Collaboration graph
[legend]

Public Member Functions

 Endpoint (const DeserializePacketFunction &deserialize_packet_function, std::shared_ptr< Logger::Log > logger) noexcept
 Construct with a packet factory and a logger.
 
 Endpoint (const Endpoint &other)=delete
 Copy constructor (deleted).
 
 Endpoint (Endpoint &&other) noexcept=default
 Move constructor.
 
virtual ~Endpoint () noexcept=default
 Destructor.
 
Endpointoperator= (const Endpoint &other)=delete
 Copy assignment (deleted).
 
Endpointoperator= (Endpoint &&other) noexcept=default
 Move assignment.
 
virtual bool Connect (const Connection::Protocol &protocol, const std::string &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

std::shared_ptr< Connection::Client > CreateConnection (std::shared_ptr< Socket::Client > socket) noexcept
 Wrap a socket client with input/output pipelines.
 
virtual Buffer::Pipeline InputPipeline () const noexcept=0
 Pipeline applied to inbound frame payloads.
 
virtual Buffer::Pipeline OutputPipeline () const noexcept=0
 Pipeline applied to outbound frame payloads.
 
PacketPointer Send (std::shared_ptr< Connection::Client > client_connection, const Transport::Packet &packet) noexcept
 Send packet and wait for a response frame.
 
bool Reply (std::shared_ptr< 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.
 
std::shared_ptr< Logger::Log > m_logger
 Logger.
 

Detailed Description

Shared base for Client and Server.

Not instantiated directly. Override InputPipeline() / OutputPipeline(). 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 ( const DeserializePacketFunction deserialize_packet_function,
std::shared_ptr< 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).

◆ Endpoint() [3/3]

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

Move constructor.

◆ ~Endpoint()

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

Destructor.

Member Function Documentation

◆ Connect()

virtual bool StormByte::Network::Endpoint::Connect ( const Connection::Protocol protocol,
const std::string &  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()

std::shared_ptr< Connection::Client > StormByte::Network::Endpoint::CreateConnection ( std::shared_ptr< Socket::Client >  socket)
protectednoexcept

Wrap a socket client with 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.

◆ InputPipeline()

virtual Buffer::Pipeline StormByte::Network::Endpoint::InputPipeline ( ) const
protectedpure virtualnoexcept

Pipeline applied to inbound frame payloads.

Returns
Pipeline.

◆ operator=() [1/2]

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

Copy assignment (deleted).

◆ operator=() [2/2]

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

Move assignment.

◆ OutputPipeline()

virtual Buffer::Pipeline StormByte::Network::Endpoint::OutputPipeline ( ) const
protectedpure virtualnoexcept

Pipeline applied to outbound frame payloads.

Returns
Pipeline.

◆ Reply()

bool StormByte::Network::Endpoint::Reply ( std::shared_ptr< 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 ( std::shared_ptr< 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.

◆ m_logger

std::shared_ptr<Logger::Log> StormByte::Network::Endpoint::m_logger
protected

Logger.


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