StormByte C++ Library: Network module 0.0.9999
StormByte-Network is a StormByte library module for handling and create network connections
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
StormByte::Network::Server Class Referenceabstract

Abstract base for application-specific servers. More...

#include <server.hxx>

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

Public Member Functions

 Server (const DeserializePacketFunction &deserialize_packet_function, std::shared_ptr< Logger::Log > logger) noexcept
 Constructs a Server instance.
 
 Server (const Server &other)=delete
 Copy constructor (deleted).
 
 Server (Server &&other) noexcept=default
 Move constructor.
 
virtual ~Server () noexcept
 Virtual destructor.
 
Serveroperator= (const Server &other)=delete
 Copy-assignment operator (deleted).
 
Serveroperator= (Server &&other) noexcept=default
 Move-assignment operator.
 
bool Connect (const Connection::Protocol &protocol, const std::string &address, const unsigned short &port) override
 Start the server and begin listening for connections.
 
void Disconnect () noexcept override
 Stop the server and disconnect all clients.
 
Connection::Status Status () const noexcept override
 Gets the current server connection status.
 

Protected Member Functions

void DisconnectClient (const std::string &uuid) noexcept
 Disconnects a client by UUID.
 

Detailed Description

Abstract base for application-specific servers.

Subclass Server to implement your server-side application logic. The constructor accepts a DeserializePacketFunction and a Logger::ThreadedLog instance; the deserializer converts opcode + payload bytes into concrete Transport::Packet instances used by the framework.

Key extension points:

Implementation notes:

Constructor & Destructor Documentation

◆ Server()

StormByte::Network::Server::Server ( const DeserializePacketFunction deserialize_packet_function,
std::shared_ptr< Logger::Log >  logger 
)
noexcept

Constructs a Server instance.

Parameters
deserialize_packet_functionFunction used to deserialize incoming transport packets into domain Packet objects.
loggerLogger instance used for diagnostic messages.

◆ ~Server()

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

Virtual destructor.

Declared pure to make Server an abstract base. Concrete subclasses must provide an implementation for the destructor (even if defaulted) in their translation unit.

Member Function Documentation

◆ Connect()

bool StormByte::Network::Server::Connect ( const Connection::Protocol &  protocol,
const std::string &  address,
const unsigned short &  port 
)
overridevirtual

Start the server and begin listening for connections.

Parameters
protocolThe protocol to use for the server.
addressThe address to bind to.
portThe port to listen on.
Returns
True if the server started successfully, false otherwise.

Implements StormByte::Network::Endpoint.

◆ Disconnect()

void StormByte::Network::Server::Disconnect ( )
overridevirtualnoexcept

Stop the server and disconnect all clients.

Implements StormByte::Network::Endpoint.

◆ DisconnectClient()

void StormByte::Network::Server::DisconnectClient ( const std::string &  uuid)
protectednoexcept

Disconnects a client by UUID.

Parameters
client_uuidThe UUID of the client to be disconnected.

◆ Status()

Connection::Status StormByte::Network::Server::Status ( ) const
inlineoverridevirtualnoexcept

Gets the current server connection status.

Returns
The current connection status.

Implements StormByte::Network::Endpoint.


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