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 | List of all members
StormByte::Network::Client Class Reference

The class representing a client. More...

#include <client.hxx>

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

Public Member Functions

 Client (const Connection::Protocol &protocol, std::shared_ptr< Connection::Handler > handler, std::shared_ptr< Logger > logger, const PacketInstanceFunction &pf) noexcept
 The constructor of the Client class.
 
 Client (const Client &other)=delete
 The copy constructor of the Client class.
 
 Client (Client &&other) noexcept=default
 The move constructor of the Client class.
 
virtual ~Client () noexcept override
 The destructor of the Client class.
 
Clientoperator= (const Client &other)=delete
 The assignment operator of the Client class.
 
Clientoperator= (Client &&other) noexcept=default
 The assignment operator of the Client class.
 
StormByte::Expected< void, ConnectionErrorConnect (const std::string &hostname, const unsigned short &port) noexcept
 The function to connect a server.
 
void Disconnect () noexcept
 The function to disconnect the server.
 
ExpectedPacket Send (const Packet &packet) noexcept
 The function to send data to the server.
 
- Public Member Functions inherited from 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.
 
 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.
 
EndPointoperator= (const EndPoint &other)=delete
 Deleted copy assignment operator to prevent copying.
 
EndPointoperator= (EndPoint &&other) noexcept=default
 Defaulted move assignment operator.
 
const Connection::Protocol & Protocol () const noexcept
 Retrieves the protocol used by the endpoint.
 

Additional Inherited Members

- Protected Attributes inherited from StormByte::Network::EndPoint
Connection::Protocol m_protocol
 The protocol used by the endpoint (e.g., IPv4, IPv6).
 
std::shared_ptr< Connection::Handlerm_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.
 

Detailed Description

The class representing a client.

Constructor & Destructor Documentation

◆ Client() [1/3]

StormByte::Network::Client::Client ( const Connection::Protocol &  protocol,
std::shared_ptr< Connection::Handler handler,
std::shared_ptr< Logger >  logger,
const PacketInstanceFunction pf 
)
noexcept

The constructor of the Client class.

Parameters
addressThe address of the server.
handlerThe handler of the server.
pfThe function to create a packet instance from opcode

◆ Client() [2/3]

StormByte::Network::Client::Client ( const Client other)
delete

The copy constructor of the Client class.

Parameters
otherThe other server to copy.

◆ Client() [3/3]

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

The move constructor of the Client class.

Parameters
otherThe other server to move.

Member Function Documentation

◆ Connect()

StormByte::Expected< void, ConnectionError > StormByte::Network::Client::Connect ( const std::string &  hostname,
const unsigned short &  port 
)
noexcept

The function to connect a server.

Parameters
hostnameThe hostname of the server.
portThe port of the server.
protocolThe protocol of the server.
Returns
The expected void or error.

◆ operator=() [1/2]

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

The assignment operator of the Client class.

Parameters
otherThe other server to assign.
Returns
The reference to the assigned server.

◆ operator=() [2/2]

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

The assignment operator of the Client class.

Parameters
otherThe other server to assign.
Returns
The reference to the assigned server.

◆ Send()

ExpectedPacket StormByte::Network::Client::Send ( const Packet packet)
noexcept

The function to send data to the server.

Parameters
packetThe packet to send.
Returns
The expected void or error.

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