shooter/engine/network/UDPConnection.h

30 lines
713 B
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Neirokan on 30.04.2020
//
#ifndef ENGINE_UDPCONNECTION_H
#define ENGINE_UDPCONNECTION_H
#include <SFML/Network.hpp>
class UDPConnection final {
2021-09-13 15:53:43 +03:00
private:
2021-10-28 16:58:02 +03:00
const sf::Uint16 _id;
const sf::IpAddress _ip;
const sf::Uint16 _port;
2021-09-13 15:53:43 +03:00
double lastMsg;
public:
explicit UDPConnection(sf::Uint16 id, sf::IpAddress ip, sf::Uint16 port);
[[nodiscard]] sf::Uint16 id() const;
[[nodiscard]] const sf::IpAddress& ip() const;
[[nodiscard]] sf::Uint16 port() const;
[[nodiscard]] bool timeout() const;
bool same(sf::IpAddress& ip, sf::Uint16 port) const;
void update();
void send(sf::UdpSocket& socket, sf::Packet& packet);
};
#endif //INC_3DZAVR_UDPCONNECTION_H