shooter/engine/network/ServerUDP.h

50 lines
1.1 KiB
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Neirokan on 30.04.2020
//
#ifndef ENGINE_SERVERUDP_H
#define ENGINE_SERVERUDP_H
2021-10-09 13:41:12 +03:00
#include "../World.h"
#include "../Camera.h"
2021-09-13 15:53:43 +03:00
#include "ReliableMsg.h"
#include "UDPSocket.h"
#include <memory>
#include <set>
class ServerUDP
{
protected:
UDPSocket _socket;
double _lastBroadcast;
bool _working;
bool process();
bool timeout(sf::Uint16 id);
std::set<sf::Uint16> _clients{};
public:
explicit ServerUDP();
[[nodiscard]] bool isWorking() const;
bool start(sf::Uint16 port);
void stop();
void update();
virtual void updateInfo(){};
// virtual functions
virtual void broadcast(){};
2021-10-03 07:47:05 +03:00
// here you have to send Init message _back to 'targetId' and send NewClient message to all '_clients'
2021-09-13 15:53:43 +03:00
virtual void processConnect(sf::Uint16 senderId){};
virtual void processClientUpdate(sf::Uint16 senderId, sf::Packet& packet){};
virtual void processDisconnect(sf::Uint16 senderId){};
virtual void processCustomPacket(MsgType type, sf::Packet& packet, sf::Uint16 senderId){};
virtual void processStop(){};
};
#endif //INC_3DZAVR_SERVERUDP_H