2014-07-06 19:54:47 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "GameServerConnection.h"
|
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
class GameServer : public IGameBroadcaster, public INotificationListener
|
2014-07-06 19:54:47 -04:00
|
|
|
{
|
|
|
|
private:
|
2014-07-09 18:29:07 -04:00
|
|
|
static unique_ptr<GameServer> Instance;
|
|
|
|
unique_ptr<thread> _serverThread;
|
|
|
|
atomic<bool> _stop;
|
|
|
|
|
|
|
|
unique_ptr<Socket> _listener;
|
2014-07-06 19:54:47 -04:00
|
|
|
list<shared_ptr<GameServerConnection>> _openConnections;
|
|
|
|
bool _initialized = false;
|
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
void AcceptConnections();
|
|
|
|
void UpdateConnections();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
void Start();
|
|
|
|
void Exec();
|
|
|
|
void Stop();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
|
|
|
public:
|
2014-07-09 18:29:07 -04:00
|
|
|
GameServer();
|
|
|
|
~GameServer();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
static void StartServer();
|
|
|
|
static void StopServer();
|
|
|
|
static bool Started();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
virtual void BroadcastInput(uint8_t inputData, uint8_t port);
|
|
|
|
virtual void ProcessNotification(ConsoleNotificationType type);
|
2014-07-06 19:54:47 -04:00
|
|
|
};
|