2014-07-06 19:54:47 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
2016-02-05 23:14:27 -05:00
|
|
|
#include <deque>
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "GameConnection.h"
|
2016-02-05 23:14:27 -05:00
|
|
|
#include "StandardController.h"
|
2014-07-09 21:48:54 -04:00
|
|
|
#include "INotificationListener.h"
|
2017-11-19 23:08:23 -05:00
|
|
|
#include "BaseControlDevice.h"
|
|
|
|
#include "ControlDeviceState.h"
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2016-02-06 15:33:45 -05:00
|
|
|
class HandShakeMessage;
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
class GameServerConnection : public GameConnection, public INotificationListener
|
2014-07-06 19:54:47 -04:00
|
|
|
{
|
|
|
|
private:
|
2017-11-19 23:08:23 -05:00
|
|
|
static GameServerConnection* _netPlayDevices[BaseControlDevice::PortCount];
|
2016-02-06 15:33:45 -05:00
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
list<ControlDeviceState> _inputData;
|
2018-06-16 14:02:12 -04:00
|
|
|
string _playerName;
|
2016-02-05 23:14:27 -05:00
|
|
|
int _controllerPort;
|
2018-06-16 14:02:12 -04:00
|
|
|
string _connectionHash;
|
|
|
|
string _serverPassword;
|
2014-07-06 19:54:47 -04:00
|
|
|
bool _handshakeCompleted = false;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
void PushState(ControlDeviceState state);
|
2018-06-16 14:02:12 -04:00
|
|
|
void SendServerInformation();
|
2016-02-05 23:14:27 -05:00
|
|
|
void SendGameInformation();
|
2016-02-06 15:33:45 -05:00
|
|
|
void SelectControllerPort(uint8_t port);
|
|
|
|
|
2016-02-10 23:07:42 -05:00
|
|
|
void SendForceDisconnectMessage(string disconnectMessage);
|
|
|
|
|
2016-02-06 15:33:45 -05:00
|
|
|
void ProcessHandshakeResponse(HandShakeMessage* message);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
static void RegisterNetPlayDevice(GameServerConnection* connection, uint8_t port);
|
|
|
|
static void UnregisterNetPlayDevice(GameServerConnection* device);
|
2016-02-06 15:33:45 -05:00
|
|
|
static uint8_t GetFirstFreeControllerPort();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
|
|
|
protected:
|
2016-12-17 23:14:47 -05:00
|
|
|
void ProcessMessage(NetMessage* message) override;
|
2014-07-06 19:54:47 -04:00
|
|
|
|
|
|
|
public:
|
2018-06-16 14:02:12 -04:00
|
|
|
GameServerConnection(shared_ptr<Socket> socket, string serverPassword);
|
2018-06-11 19:07:05 -04:00
|
|
|
virtual ~GameServerConnection();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
ControlDeviceState GetState();
|
|
|
|
void SendMovieData(uint8_t port, ControlDeviceState state);
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2016-02-06 15:33:45 -05:00
|
|
|
string GetPlayerName();
|
|
|
|
uint8_t GetControllerPort();
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
static GameServerConnection* GetNetPlayDevice(uint8_t port);
|
2014-07-06 19:54:47 -04:00
|
|
|
};
|