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 <StormByte/network/packet.hxx>
5
15 class STORMBYTE_NETWORK_PUBLIC Client: public EndPoint {
16 public:
23 Client(const Connection::Protocol& protocol, std::shared_ptr<Connection::Handler> handler, std::shared_ptr<Logger> logger, const PacketInstanceFunction& pf) noexcept;
24
29 Client(const Client& other) = delete;
30
35 Client(Client&& other) noexcept = default;
36
40 virtual ~Client() noexcept override;
41
47 Client& operator=(const Client& other) = delete;
48
54 Client& operator=(Client&& other) noexcept = default;
55
63 StormByte::Expected<void, ConnectionError> Connect(const std::string& hostname, const unsigned short& port) noexcept;
64
68 void Disconnect() noexcept;
69
75 ExpectedPacket Send(const Packet& packet) noexcept;
76
77 private:
78 PacketInstanceFunction m_packet_instance_function;
79
84 ExpectedPacket Receive() noexcept;
85 };
86}
The class representing a client.
Definition client.hxx:15
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.
virtual ~Client() noexcept override
The destructor of the Client class.
Client(Client &&other) noexcept=default
The move constructor of the Client class.
The class representing an error in the connection.
Definition exception.hxx:27
Represents a network endpoint, serving as a base class for both clients and servers.
Definition endpoint.hxx:17
The class representing a packet. Explicitelly instantiate this class to get packets identified by the...
Definition packet.hxx:18
Contains all the network-related classes and utilities.
Definition client.hxx:10
StormByte::Expected< std::shared_ptr< Packet >, PacketError > ExpectedPacket
The expected packet type.
Definition typedefs.hxx:37
std::function< std::shared_ptr< Packet >(const unsigned short &)> PacketInstanceFunction
The packet instance function type.
Definition typedefs.hxx:38