2#include <SFML/Network/IpAddress.hpp>
3#include <SFML/Network/TcpListener.hpp>
5#include "network_client.h"
16 ClientId clientId = INVALID_CLIENT_ID;
17 unsigned long long timeDifference = 0;
18 sf::IpAddress udpRemoteAddress;
19 unsigned short udpRemotePort = 0;
28 enum class PacketSocketSource
34 void SendReliablePacket(std::unique_ptr<Packet> packet)
override;
36 void SendUnreliablePacket(std::unique_ptr<Packet> packet)
override;
38 void Begin()
override;
40 void Update(sf::Time dt)
override;
44 void SetTcpPort(
unsigned short i);
46 [[nodiscard]]
bool IsOpen()
const;
52 void ProcessReceivePacket(std::unique_ptr<Packet> packet,
53 PacketSocketSource packetSource,
54 sf::IpAddress address =
"localhost",
55 unsigned short port = 0);
56 void ReceiveNetPacket(sf::Packet& packet, PacketSocketSource packetSource,
57 sf::IpAddress address =
"localhost",
58 unsigned short port = 0);
64 FIRST_PLAYER_CONNECT = 1u << 2u,
66 sf::UdpSocket udpSocket_;
67 sf::TcpListener tcpListener_;
68 std::array<sf::TcpSocket, maxPlayerNmb> tcpSockets_;
70 std::array<ClientInfo, maxPlayerNmb> clientInfoMap_{};
73 unsigned short tcpPort_ = 12345;
74 unsigned short udpPort_ = 12345;
75 std::uint32_t lastSocketIndex_ = 0;
76 std::uint8_t status_ = 0;
NetworkServer is a network server using SFML sockets.
Definition: network_server.h:26
Server is an interface to a network or simulated server. It owns a simple GameManager.
Definition: server.h:15
ClientId
ClientId is a type used to define the client identification. It is given by the server to clients.
Definition: game_globals.h:31
std::uint8_t PlayerNumber
PlayerNumber is a type used to define the number of the player. Starting from 0 to maxPlayerNmb.
Definition: game_globals.h:22
ClientInfo is a struct used by a network server to store all needed infos about a client.
Definition: network_server.h:15