mirror of
https://github.com/HikikoMarmy/Champions-Reborn-Server.git
synced 2026-04-05 00:49:48 -03:00
Reorganized and cleaned up the solution.
This commit is contained in:
43
Include/Discovery Server/DiscoveryServer.hpp
Normal file
43
Include/Discovery Server/DiscoveryServer.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#include "Common/ByteStream.hpp"
|
||||
|
||||
class DiscoveryServer {
|
||||
public:
|
||||
static DiscoveryServer &Get()
|
||||
{
|
||||
static DiscoveryServer instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
DiscoveryServer( const DiscoveryServer & ) = delete;
|
||||
DiscoveryServer &operator=( const DiscoveryServer & ) = delete;
|
||||
DiscoveryServer();
|
||||
~DiscoveryServer();
|
||||
|
||||
void Start( std::string ip, int32_t port );
|
||||
void Stop();
|
||||
void Run();
|
||||
bool isRunning() const
|
||||
{
|
||||
return m_running;
|
||||
}
|
||||
|
||||
private:
|
||||
void ProcessPacket( sockaddr_in *clientAddr, sptr_byte_stream stream );
|
||||
|
||||
std::atomic< bool > m_running;
|
||||
std::thread m_thread;
|
||||
|
||||
SOCKET m_socket;
|
||||
std::vector< unsigned char > m_recvBuffer;
|
||||
};
|
||||
Reference in New Issue
Block a user