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
client.hxx
1#pragma once
2
3#include <StormByte/network/endpoint.hxx>
4#include <string>
5#include <memory>
6
11namespace StormByte::Network {
12 namespace Connection {
13 class Client;
14 }
15
41 class STORMBYTE_NETWORK_PUBLIC Client: private Endpoint {
42 public:
50 inline Client(const DeserializePacketFunction& deserialize_packet_function, std::shared_ptr<Logger::Log> logger) noexcept:
51 Endpoint(deserialize_packet_function, logger),
52 m_connection(nullptr) {}
53
57 Client(const Client& other) = delete;
58
62 Client(Client&& other) noexcept = default;
63
70 virtual ~Client() noexcept;
71
75 Client& operator=(const Client& other) = delete;
76
80 Client& operator=(Client&& other) noexcept = default;
81
90 bool Connect(const Connection::Protocol& protocol, const std::string& address, const unsigned short& port) override;
91
95 void Disconnect() noexcept override;
96
102 Connection::Status Status() const noexcept override;
103
104 protected:
117 PacketPointer Send(const Transport::Packet& packet) noexcept;
118
119 private:
120 std::shared_ptr<Connection::Client> m_connection;
121 };
122}
Abstract base class for application-specific clients.
Definition client.hxx:41
virtual ~Client() noexcept
Virtual destructor (abstract).
Client(const DeserializePacketFunction &deserialize_packet_function, std::shared_ptr< Logger::Log > logger) noexcept
Constructs a Client instance.
Definition client.hxx:50
Client(const Client &other)=delete
Copy constructor (deleted).
Client(Client &&other) noexcept=default
Move constructor.
Abstract base for network endpoints (clients/servers).
Definition endpoint.hxx:26
The namespace containing connection items.
Network-related classes used by the StormByte networking subsystem.
std::function< PacketPointer(Transport::Packet::OpcodeType, Buffer::Consumer, std::shared_ptr< Logger::Log >)> DeserializePacketFunction
The deserialize packet function type.
Definition typedefs.hxx:43
std::shared_ptr< Transport::Packet > PacketPointer
The packet pointer type.
Definition typedefs.hxx:38
Application-layer transport types: packets, frames and serialization.