38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <netdb.h>
|
|
#include <thread>
|
|
|
|
#include "Peer.hpp"
|
|
#include "events/types.hpp"
|
|
#include "events/base/BaseEvent.hpp"
|
|
#include "tasks/types.hpp"
|
|
#include "tasks/base/BaseTask.hpp"
|
|
#include "utils/StatList.hpp"
|
|
|
|
|
|
class EventManager {
|
|
public:
|
|
EventManager();
|
|
|
|
void loop();
|
|
void loopSender();
|
|
void loopReceiver();
|
|
|
|
private:
|
|
std::thread senderThread; /// the thread sending communication
|
|
std::thread receiverThread; /// the thread receiving communication
|
|
|
|
std::map<drp::event::EventType, std::shared_ptr<drp::event::BaseEvent>> eventRegistry; /// hold the event to call depending on the event type
|
|
std::map<drp::task::TaskType, std::shared_ptr<drp::task::BaseTask>> taskRegistry; /// hold the task to call depending on the server status
|
|
|
|
StatList<std::shared_ptr<Peer>> peers; /// list of peers found
|
|
std::shared_ptr<Peer> server; /// the peer used as a server
|
|
|
|
int eventSocket; /// the socket used to communicate
|
|
drp::task::TaskType status; /// our current status
|
|
|
|
std::uint8_t channel; /// the packet channel currently used
|
|
};
|