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
endpoint.hxx
1#pragma once
2
3#include <StormByte/buffer/pipeline.hxx>
4#include <StormByte/logger/threaded_log.hxx>
5#include <StormByte/network/typedefs.hxx>
6
12namespace StormByte::Network {
13 namespace Connection {
14 class Client;
15 }
16
26 class STORMBYTE_NETWORK_PUBLIC Endpoint {
27 public:
36 Endpoint(const DeserializePacketFunction& deserialize_packet_function, std::shared_ptr<Logger::Log> logger) noexcept;
37
43 Endpoint(const Endpoint& other) = delete;
44
51 Endpoint(Endpoint&& other) noexcept = default;
52
60 virtual ~Endpoint() noexcept = default;
61
67 Endpoint& operator=(const Endpoint& other) = delete;
68
75 Endpoint& operator=(Endpoint&& other) noexcept = default;
76
84 virtual bool Connect(const Connection::Protocol& protocol, const std::string& address, const unsigned short& port) = 0;
85
89 virtual void Disconnect() noexcept = 0;
90
96 virtual Connection::Status Status() const noexcept = 0;
97
98 protected:
99 DeserializePacketFunction m_deserialize_packet_function;
100 std::shared_ptr<Logger::Log> m_logger;
101
108 std::shared_ptr<Connection::Client> CreateConnection(std::shared_ptr<Socket::Client> socket) noexcept;
109
118 virtual Buffer::Pipeline InputPipeline() const noexcept = 0;
119
128 virtual Buffer::Pipeline OutputPipeline() const noexcept = 0;
129
144 PacketPointer Send(std::shared_ptr<Connection::Client> client_connection, const Transport::Packet& packet) noexcept;
145
157 bool Reply(std::shared_ptr<Connection::Client> client_connection, const Transport::Packet& packet) noexcept;
158
159 private:
167 bool SendPacket(std::shared_ptr<Connection::Client> client_connection, const Transport::Packet& packet) noexcept;
168 };
169}
Abstract base class for application-specific clients.
Definition client.hxx:41
Abstract base for network endpoints (clients/servers).
Definition endpoint.hxx:26
Endpoint(Endpoint &&other) noexcept=default
Move constructor.
virtual ~Endpoint() noexcept=default
Virtual destructor.
Endpoint(const Endpoint &other)=delete
Copy constructor (deleted).
Endpoint(const DeserializePacketFunction &deserialize_packet_function, std::shared_ptr< Logger::Log > logger) noexcept
Constructs an Endpoint.
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.