Network code documentation for my turn-based game 1.0
Loading...
Searching...
No Matches
client_network_manager.h
Go to the documentation of this file.
1#pragma once
2
3#include "types.h"
5
6#include <SFML/Network.hpp>
7
13public:
14 ClientNetworkManager() noexcept = default;
15 ClientNetworkManager(ClientNetworkManager&& other) noexcept = delete;
16 ClientNetworkManager& operator=(ClientNetworkManager&& other) noexcept = delete;
17 ClientNetworkManager(const ClientNetworkManager& other) noexcept = delete;
19 const ClientNetworkManager& other) noexcept = delete;
20 ~ClientNetworkManager() noexcept override = default;
21
22 void SendPacket(sf::Packet& packet) noexcept override;
23 [[nodiscard]] PacketType ReceivePacket(sf::Packet& packet) noexcept override;
24
26 unsigned short remote_port,
27 bool blocking = true) noexcept;
28
29 void DisconnectFromServer() noexcept;
30
31 [[nodiscard]] sf::IpAddress remote_address() const noexcept {
32 return socket_.getRemoteAddress();
33 }
34 [[nodiscard]] unsigned short remote_port() const noexcept {
35 return socket_.getRemotePort();
36 }
37
38private:
39 sf::TcpSocket socket_{};
40};
ClientNetworkInterface is an interface to communicates with a server.
Definition client_network_interface.h:8
ClientNetworkManager is the implementation of the ClientNetworkInterface. It manages the communicatio...
Definition client_network_manager.h:12
unsigned short remote_port() const noexcept
Definition client_network_manager.h:34
PacketType ReceivePacket(sf::Packet &packet) noexcept override
ClientNetworkManager() noexcept=default
sf::IpAddress remote_address() const noexcept
Definition client_network_manager.h:31
void DisconnectFromServer() noexcept
ReturnStatus ConnectToServer(const sf::IpAddress &remote_address, unsigned short remote_port, bool blocking=true) noexcept
void SendPacket(sf::Packet &packet) noexcept override
PacketType
Definition packet.h:7
ReturnStatus
Definition types.h:6