StormByte C++ Library: Network module 1.1.0
StormByte-Network is the C++26 networking module of the StormByte suite.
Loading...
Searching...
No Matches
client.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Network.
5 *
6 * StormByte-Network is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
9 *
10 * StormByte-Network is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte-Network. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
18 */
19
20#pragma once
21
23
24#include <memory>
25#include <string>
26
31 namespace Connection {
32 class Client;
33 }
34
44 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
67 virtual ~Client() noexcept;
68
72 Client& operator=(const Client& other) = delete;
73
77 Client& operator=(Client&& other) noexcept = default;
78
86 bool Connect(const Connection::Protocol& protocol, const std::string& address, const unsigned short& port) override;
87
91 void Disconnect() noexcept override;
92
97 Connection::Status Status() const noexcept override;
98
99 protected:
105 PacketPointer Send(const Transport::Packet& packet) noexcept;
106
107 private:
108 std::shared_ptr<Connection::Client> m_connection;
109 };
110}
Abstract application client.
Definition client.hxx:43
virtual ~Client() noexcept
Destructor (out-of-line in .cxx).
Client(const DeserializePacketFunction &deserialize_packet_function, std::shared_ptr< Logger::Log > logger) noexcept
Construct with a packet factory and a logger.
Definition client.hxx:50
Client(const Client &other)=delete
Copy constructor (deleted).
Client(Client &&other) noexcept=default
Move constructor.
Shared base for Client and Server.
Definition endpoint.hxx:42
Network module of the StormByte suite.
Definition client.hxx:30
std::function< PacketPointer(Transport::Packet::OpcodeType, Buffer::Consumer, std::shared_ptr< Logger::Log >)> DeserializePacketFunction
Callback that builds a Packet from opcode + payload consumer.
Definition typedefs.hxx:68
std::shared_ptr< Transport::Packet > PacketPointer
Shared packet.
Definition typedefs.hxx:59
#define STORMBYTE_NETWORK_PUBLIC
Definition visibility.h:28