2014-07-06 19:54:47 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
2016-02-05 23:14:27 -05:00
|
|
|
#include <thread>
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "INotificationListener.h"
|
2018-07-01 15:21:05 -04:00
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
using std::thread;
|
|
|
|
class Socket;
|
|
|
|
class GameClientConnection;
|
2015-07-01 23:17:14 -04:00
|
|
|
class ClientConnectionData;
|
2018-07-01 15:21:05 -04:00
|
|
|
class Console;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
class GameClient : public INotificationListener
|
2014-07-06 19:54:47 -04:00
|
|
|
{
|
|
|
|
private:
|
2017-11-14 00:00:00 -05:00
|
|
|
static shared_ptr<GameClient> _instance;
|
2018-07-01 15:21:05 -04:00
|
|
|
|
|
|
|
shared_ptr<Console> _console;
|
2014-07-09 18:29:07 -04:00
|
|
|
unique_ptr<thread> _clientThread;
|
|
|
|
atomic<bool> _stop;
|
|
|
|
|
2017-11-14 00:00:00 -05:00
|
|
|
shared_ptr<GameClientConnection> _connection;
|
2014-07-06 19:54:47 -04:00
|
|
|
bool _connected = false;
|
|
|
|
|
2017-11-14 00:00:00 -05:00
|
|
|
static shared_ptr<GameClientConnection> GetConnection();
|
|
|
|
|
2018-06-16 14:02:12 -04:00
|
|
|
void PrivateConnect(ClientConnectionData &connectionData);
|
2014-07-09 18:29:07 -04:00
|
|
|
void Exec();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
public:
|
2018-07-01 15:21:05 -04:00
|
|
|
GameClient(shared_ptr<Console> console);
|
2018-06-11 19:07:05 -04:00
|
|
|
virtual ~GameClient();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
static bool Connected();
|
2018-07-01 15:21:05 -04:00
|
|
|
static void Connect(shared_ptr<Console> console, ClientConnectionData &connectionData);
|
2014-07-09 18:29:07 -04:00
|
|
|
static void Disconnect();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2016-02-06 15:33:45 -05:00
|
|
|
static void SelectController(uint8_t port);
|
|
|
|
static uint8_t GetControllerPort();
|
|
|
|
static uint8_t GetAvailableControllers();
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
|
2014-07-09 18:29:07 -04:00
|
|
|
};
|