Netplay: Added password protected servers
This commit is contained in:
parent
c0c0fa606b
commit
7619b93cfe
34 changed files with 215 additions and 174 deletions
|
@ -7,13 +7,14 @@ class ClientConnectionData
|
||||||
public:
|
public:
|
||||||
string Host;
|
string Host;
|
||||||
uint16_t Port;
|
uint16_t Port;
|
||||||
|
string Password;
|
||||||
string PlayerName;
|
string PlayerName;
|
||||||
|
|
||||||
bool Spectator;
|
bool Spectator;
|
||||||
|
|
||||||
ClientConnectionData(string host, uint16_t port, string playerName, bool spectator) :
|
ClientConnectionData() {}
|
||||||
Host(host), Port(port), PlayerName(playerName), Spectator(spectator)
|
|
||||||
|
ClientConnectionData(string host, uint16_t port, string password, string playerName, bool spectator) :
|
||||||
|
Host(host), Port(port), Password(password), PlayerName(playerName), Spectator(spectator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -531,6 +531,7 @@
|
||||||
<ClInclude Include="MovieRecorder.h" />
|
<ClInclude Include="MovieRecorder.h" />
|
||||||
<ClInclude Include="AsciiTurboFile.h" />
|
<ClInclude Include="AsciiTurboFile.h" />
|
||||||
<ClInclude Include="RawVideoFilter.h" />
|
<ClInclude Include="RawVideoFilter.h" />
|
||||||
|
<ClInclude Include="ServerInformationMessage.h" />
|
||||||
<ClInclude Include="SystemActionManager.h" />
|
<ClInclude Include="SystemActionManager.h" />
|
||||||
<ClInclude Include="DatachBarcodeReader.h" />
|
<ClInclude Include="DatachBarcodeReader.h" />
|
||||||
<ClInclude Include="DebugHud.h" />
|
<ClInclude Include="DebugHud.h" />
|
||||||
|
|
|
@ -1372,6 +1372,9 @@
|
||||||
<ClInclude Include="BaseSoundManager.h">
|
<ClInclude Include="BaseSoundManager.h">
|
||||||
<Filter>Misc</Filter>
|
<Filter>Misc</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="ServerInformationMessage.h">
|
||||||
|
<Filter>NetPlay\Messages</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
|
|
@ -33,7 +33,7 @@ bool GameClient::Connected()
|
||||||
return instance ? instance->_connected : false;
|
return instance ? instance->_connected : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameClient::Connect(shared_ptr<ClientConnectionData> connectionData)
|
void GameClient::Connect(ClientConnectionData &connectionData)
|
||||||
{
|
{
|
||||||
_instance.reset(new GameClient());
|
_instance.reset(new GameClient());
|
||||||
|
|
||||||
|
@ -55,11 +55,11 @@ shared_ptr<GameClientConnection> GameClient::GetConnection()
|
||||||
return instance ? instance->_connection : nullptr;
|
return instance ? instance->_connection : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameClient::PrivateConnect(shared_ptr<ClientConnectionData> connectionData)
|
void GameClient::PrivateConnect(ClientConnectionData &connectionData)
|
||||||
{
|
{
|
||||||
_stop = false;
|
_stop = false;
|
||||||
shared_ptr<Socket> socket(new Socket());
|
shared_ptr<Socket> socket(new Socket());
|
||||||
if(socket->Connect(connectionData->Host.c_str(), connectionData->Port)) {
|
if(socket->Connect(connectionData.Host.c_str(), connectionData.Port)) {
|
||||||
_connection.reset(new GameClientConnection(socket, connectionData));
|
_connection.reset(new GameClientConnection(socket, connectionData));
|
||||||
_connected = true;
|
_connected = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,7 +19,7 @@ private:
|
||||||
|
|
||||||
static shared_ptr<GameClientConnection> GetConnection();
|
static shared_ptr<GameClientConnection> GetConnection();
|
||||||
|
|
||||||
void PrivateConnect(shared_ptr<ClientConnectionData> connectionData);
|
void PrivateConnect(ClientConnectionData &connectionData);
|
||||||
void Exec();
|
void Exec();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -27,7 +27,7 @@ public:
|
||||||
virtual ~GameClient();
|
virtual ~GameClient();
|
||||||
|
|
||||||
static bool Connected();
|
static bool Connected();
|
||||||
static void Connect(shared_ptr<ClientConnectionData> connectionData);
|
static void Connect(ClientConnectionData &connectionData);
|
||||||
static void Disconnect();
|
static void Disconnect();
|
||||||
|
|
||||||
static void SelectController(uint8_t port);
|
static void SelectController(uint8_t port);
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
#include "SelectControllerMessage.h"
|
#include "SelectControllerMessage.h"
|
||||||
#include "PlayerListMessage.h"
|
#include "PlayerListMessage.h"
|
||||||
#include "ForceDisconnectMessage.h"
|
#include "ForceDisconnectMessage.h"
|
||||||
|
#include "ServerInformationMessage.h"
|
||||||
|
|
||||||
GameClientConnection::GameClientConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData) : GameConnection(socket, connectionData)
|
GameClientConnection::GameClientConnection(shared_ptr<Socket> socket, ClientConnectionData &connectionData) : GameConnection(socket)
|
||||||
{
|
{
|
||||||
|
_connectionData = connectionData;
|
||||||
_shutdown = false;
|
_shutdown = false;
|
||||||
_enableControllers = false;
|
_enableControllers = false;
|
||||||
_minimumQueueSize = 3;
|
_minimumQueueSize = 3;
|
||||||
|
@ -26,7 +28,6 @@ GameClientConnection::GameClientConnection(shared_ptr<Socket> socket, shared_ptr
|
||||||
MessageManager::RegisterNotificationListener(this);
|
MessageManager::RegisterNotificationListener(this);
|
||||||
MessageManager::DisplayMessage("NetPlay", "ConnectedToServer");
|
MessageManager::DisplayMessage("NetPlay", "ConnectedToServer");
|
||||||
ControlManager::RegisterInputProvider(this);
|
ControlManager::RegisterInputProvider(this);
|
||||||
SendHandshake();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientConnection::~GameClientConnection()
|
GameClientConnection::~GameClientConnection()
|
||||||
|
@ -50,7 +51,7 @@ void GameClientConnection::Shutdown()
|
||||||
|
|
||||||
void GameClientConnection::SendHandshake()
|
void GameClientConnection::SendHandshake()
|
||||||
{
|
{
|
||||||
HandShakeMessage message(_connectionData->PlayerName, _connectionData->Spectator);
|
HandShakeMessage message(_connectionData.PlayerName, HandShakeMessage::GetPasswordHash(_connectionData.Password, _serverSalt), _connectionData.Spectator);
|
||||||
SendNetMessage(message);
|
SendNetMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +75,11 @@ void GameClientConnection::ProcessMessage(NetMessage* message)
|
||||||
GameInformationMessage* gameInfo;
|
GameInformationMessage* gameInfo;
|
||||||
|
|
||||||
switch(message->GetType()) {
|
switch(message->GetType()) {
|
||||||
|
case MessageType::ServerInformation:
|
||||||
|
_serverSalt = ((ServerInformationMessage*)message)->GetHashSalt();
|
||||||
|
SendHandshake();
|
||||||
|
break;
|
||||||
|
|
||||||
case MessageType::SaveState:
|
case MessageType::SaveState:
|
||||||
if(_gameLoaded) {
|
if(_gameLoaded) {
|
||||||
DisableControllers();
|
DisableControllers();
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#include "BaseControlDevice.h"
|
#include "BaseControlDevice.h"
|
||||||
#include "IInputProvider.h"
|
#include "IInputProvider.h"
|
||||||
#include "ControlDeviceState.h"
|
#include "ControlDeviceState.h"
|
||||||
|
#include "ClientConnectionData.h"
|
||||||
class ClientConnectionData;
|
|
||||||
|
|
||||||
class GameClientConnection : public GameConnection, public INotificationListener, public IInputProvider
|
class GameClientConnection : public GameConnection, public INotificationListener, public IInputProvider
|
||||||
{
|
{
|
||||||
|
@ -28,6 +27,8 @@ private:
|
||||||
ControlDeviceState _lastInputSent;
|
ControlDeviceState _lastInputSent;
|
||||||
bool _gameLoaded = false;
|
bool _gameLoaded = false;
|
||||||
uint8_t _controllerPort = GameConnection::SpectatorPort;
|
uint8_t _controllerPort = GameConnection::SpectatorPort;
|
||||||
|
ClientConnectionData _connectionData;
|
||||||
|
string _serverSalt;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SendHandshake();
|
void SendHandshake();
|
||||||
|
@ -40,7 +41,7 @@ protected:
|
||||||
void ProcessMessage(NetMessage* message) override;
|
void ProcessMessage(NetMessage* message) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameClientConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData);
|
GameClientConnection(shared_ptr<Socket> socket, ClientConnectionData &connectionData);
|
||||||
virtual ~GameClientConnection();
|
virtual ~GameClientConnection();
|
||||||
|
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
#include "SelectControllerMessage.h"
|
#include "SelectControllerMessage.h"
|
||||||
#include "ClientConnectionData.h"
|
#include "ClientConnectionData.h"
|
||||||
#include "ForceDisconnectMessage.h"
|
#include "ForceDisconnectMessage.h"
|
||||||
|
#include "ServerInformationMessage.h"
|
||||||
|
|
||||||
const uint32_t PlayerListMessage::PlayerNameMaxLength;
|
const uint32_t PlayerListMessage::PlayerNameMaxLength;
|
||||||
|
|
||||||
GameConnection::GameConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData)
|
GameConnection::GameConnection(shared_ptr<Socket> socket)
|
||||||
{
|
{
|
||||||
_connectionData = connectionData;
|
|
||||||
_socket = socket;
|
_socket = socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ NetMessage* GameConnection::ReadMessage()
|
||||||
case MessageType::PlayerList: return new PlayerListMessage(_messageBuffer, messageLength);
|
case MessageType::PlayerList: return new PlayerListMessage(_messageBuffer, messageLength);
|
||||||
case MessageType::SelectController: return new SelectControllerMessage(_messageBuffer, messageLength);
|
case MessageType::SelectController: return new SelectControllerMessage(_messageBuffer, messageLength);
|
||||||
case MessageType::ForceDisconnect: return new ForceDisconnectMessage(_messageBuffer, messageLength);
|
case MessageType::ForceDisconnect: return new ForceDisconnectMessage(_messageBuffer, messageLength);
|
||||||
|
case MessageType::ServerInformation: return new ServerInformationMessage(_messageBuffer, messageLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
class Socket;
|
class Socket;
|
||||||
class NetMessage;
|
class NetMessage;
|
||||||
class ClientConnectionData;
|
|
||||||
|
|
||||||
struct PlayerInfo
|
struct PlayerInfo
|
||||||
{
|
{
|
||||||
|
@ -17,7 +16,6 @@ class GameConnection
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
shared_ptr<Socket> _socket;
|
shared_ptr<Socket> _socket;
|
||||||
shared_ptr<ClientConnectionData> _connectionData;
|
|
||||||
uint8_t _readBuffer[0x40000] = {};
|
uint8_t _readBuffer[0x40000] = {};
|
||||||
uint8_t _messageBuffer[0x40000] = {};
|
uint8_t _messageBuffer[0x40000] = {};
|
||||||
int _readPosition = 0;
|
int _readPosition = 0;
|
||||||
|
@ -36,7 +34,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const uint8_t SpectatorPort = 0xFF;
|
static const uint8_t SpectatorPort = 0xFF;
|
||||||
GameConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData);
|
GameConnection(shared_ptr<Socket> socket);
|
||||||
|
|
||||||
bool ConnectionError();
|
bool ConnectionError();
|
||||||
void ProcessMessages();
|
void ProcessMessages();
|
||||||
|
|
|
@ -11,10 +11,11 @@ using std::thread;
|
||||||
|
|
||||||
unique_ptr<GameServer> GameServer::Instance;
|
unique_ptr<GameServer> GameServer::Instance;
|
||||||
|
|
||||||
GameServer::GameServer(uint16_t listenPort, string hostPlayerName)
|
GameServer::GameServer(uint16_t listenPort, string password, string hostPlayerName)
|
||||||
{
|
{
|
||||||
_stop = false;
|
_stop = false;
|
||||||
_port = listenPort;
|
_port = listenPort;
|
||||||
|
_password = password;
|
||||||
_hostPlayerName = hostPlayerName;
|
_hostPlayerName = hostPlayerName;
|
||||||
_hostControllerPort = 0;
|
_hostControllerPort = 0;
|
||||||
ControlManager::RegisterInputRecorder(this);
|
ControlManager::RegisterInputRecorder(this);
|
||||||
|
@ -37,7 +38,7 @@ void GameServer::AcceptConnections()
|
||||||
while(true) {
|
while(true) {
|
||||||
shared_ptr<Socket> socket = _listener->Accept();
|
shared_ptr<Socket> socket = _listener->Accept();
|
||||||
if(!socket->ConnectionError()) {
|
if(!socket->ConnectionError()) {
|
||||||
_openConnections.push_back(shared_ptr<GameServerConnection>(new GameServerConnection(socket)));
|
_openConnections.push_back(shared_ptr<GameServerConnection>(new GameServerConnection(socket, _password)));
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -121,9 +122,9 @@ void GameServer::Stop()
|
||||||
MessageManager::DisplayMessage("NetPlay", "ServerStopped");
|
MessageManager::DisplayMessage("NetPlay", "ServerStopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameServer::StartServer(uint16_t port, string hostPlayerName)
|
void GameServer::StartServer(uint16_t port, string password, string hostPlayerName)
|
||||||
{
|
{
|
||||||
Instance.reset(new GameServer(port, hostPlayerName));
|
Instance.reset(new GameServer(port, password, hostPlayerName));
|
||||||
Instance->_serverThread.reset(new thread(&GameServer::Exec, Instance.get()));
|
Instance->_serverThread.reset(new thread(&GameServer::Exec, Instance.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ private:
|
||||||
|
|
||||||
unique_ptr<Socket> _listener;
|
unique_ptr<Socket> _listener;
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
|
string _password;
|
||||||
list<shared_ptr<GameServerConnection>> _openConnections;
|
list<shared_ptr<GameServerConnection>> _openConnections;
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
|
|
||||||
|
@ -30,10 +31,10 @@ private:
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameServer(uint16_t port, string hostPlayerName);
|
GameServer(uint16_t port, string password, string hostPlayerName);
|
||||||
virtual ~GameServer();
|
virtual ~GameServer();
|
||||||
|
|
||||||
static void StartServer(uint16_t port, string hostPlayerName);
|
static void StartServer(uint16_t port, string password, string hostPlayerName);
|
||||||
static void StopServer();
|
static void StopServer();
|
||||||
static bool Started();
|
static bool Started();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include <random>
|
||||||
#include "MessageManager.h"
|
#include "MessageManager.h"
|
||||||
#include "GameServerConnection.h"
|
#include "GameServerConnection.h"
|
||||||
#include "HandShakeMessage.h"
|
#include "HandShakeMessage.h"
|
||||||
|
@ -16,26 +17,46 @@
|
||||||
#include "GameServer.h"
|
#include "GameServer.h"
|
||||||
#include "ForceDisconnectMessage.h"
|
#include "ForceDisconnectMessage.h"
|
||||||
#include "BaseControlDevice.h"
|
#include "BaseControlDevice.h"
|
||||||
|
#include "ServerInformationMessage.h"
|
||||||
|
|
||||||
GameServerConnection* GameServerConnection::_netPlayDevices[BaseControlDevice::PortCount] = { };
|
GameServerConnection* GameServerConnection::_netPlayDevices[BaseControlDevice::PortCount] = { };
|
||||||
|
|
||||||
GameServerConnection::GameServerConnection(shared_ptr<Socket> socket) : GameConnection(socket, nullptr)
|
GameServerConnection::GameServerConnection(shared_ptr<Socket> socket, string serverPassword) : GameConnection(socket)
|
||||||
{
|
{
|
||||||
//Server-side connection
|
//Server-side connection
|
||||||
|
_serverPassword = serverPassword;
|
||||||
_controllerPort = GameConnection::SpectatorPort;
|
_controllerPort = GameConnection::SpectatorPort;
|
||||||
MessageManager::RegisterNotificationListener(this);
|
MessageManager::RegisterNotificationListener(this);
|
||||||
|
SendServerInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameServerConnection::~GameServerConnection()
|
GameServerConnection::~GameServerConnection()
|
||||||
{
|
{
|
||||||
if(_connectionData) {
|
if(!_playerName.empty()) {
|
||||||
MessageManager::DisplayMessage("NetPlay", _connectionData->PlayerName + " (Player " + std::to_string(_controllerPort + 1) + ") disconnected.");
|
MessageManager::DisplayMessage("NetPlay", _playerName + " (Player " + std::to_string(_controllerPort + 1) + ") disconnected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
UnregisterNetPlayDevice(this);
|
UnregisterNetPlayDevice(this);
|
||||||
MessageManager::UnregisterNotificationListener(this);
|
MessageManager::UnregisterNotificationListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameServerConnection::SendServerInformation()
|
||||||
|
{
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 engine(rd());
|
||||||
|
std::uniform_int_distribution<> dist((int)' ', (int)'~');
|
||||||
|
string hash(50, ' ');
|
||||||
|
for(int i = 0; i < 50; i++) {
|
||||||
|
int random = dist(engine);
|
||||||
|
hash[i] = (char)random;
|
||||||
|
}
|
||||||
|
|
||||||
|
_connectionHash = hash;
|
||||||
|
|
||||||
|
ServerInformationMessage message(hash);
|
||||||
|
SendNetMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
void GameServerConnection::SendGameInformation()
|
void GameServerConnection::SendGameInformation()
|
||||||
{
|
{
|
||||||
Console::Pause();
|
Console::Pause();
|
||||||
|
@ -88,14 +109,15 @@ void GameServerConnection::ProcessHandshakeResponse(HandShakeMessage* message)
|
||||||
{
|
{
|
||||||
//Send the game's current state to the client and register the controller
|
//Send the game's current state to the client and register the controller
|
||||||
if(message->IsValid()) {
|
if(message->IsValid()) {
|
||||||
|
if(message->CheckPassword(_serverPassword, _connectionHash)) {
|
||||||
Console::Pause();
|
Console::Pause();
|
||||||
|
|
||||||
_controllerPort = message->IsSpectator() ? GameConnection::SpectatorPort : GetFirstFreeControllerPort();
|
_controllerPort = message->IsSpectator() ? GameConnection::SpectatorPort : GetFirstFreeControllerPort();
|
||||||
_connectionData.reset(new ClientConnectionData("", 0, message->GetPlayerName(), false));
|
_playerName = message->GetPlayerName();
|
||||||
|
|
||||||
string playerPortMessage = _controllerPort == GameConnection::SpectatorPort ? "Spectator" : "Player " + std::to_string(_controllerPort + 1);
|
string playerPortMessage = _controllerPort == GameConnection::SpectatorPort ? "Spectator" : "Player " + std::to_string(_controllerPort + 1);
|
||||||
|
|
||||||
MessageManager::DisplayMessage("NetPlay", _connectionData->PlayerName + " (" + playerPortMessage + ") connected.");
|
MessageManager::DisplayMessage("NetPlay", _playerName + " (" + playerPortMessage + ") connected.");
|
||||||
|
|
||||||
if(Console::GetMapperInfo().RomName.size() > 0) {
|
if(Console::GetMapperInfo().RomName.size() > 0) {
|
||||||
SendGameInformation();
|
SendGameInformation();
|
||||||
|
@ -105,6 +127,9 @@ void GameServerConnection::ProcessHandshakeResponse(HandShakeMessage* message)
|
||||||
RegisterNetPlayDevice(this, _controllerPort);
|
RegisterNetPlayDevice(this, _controllerPort);
|
||||||
GameServer::SendPlayerList();
|
GameServer::SendPlayerList();
|
||||||
Console::Resume();
|
Console::Resume();
|
||||||
|
} else {
|
||||||
|
SendForceDisconnectMessage("The password you provided did not match - you have been disconnected.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SendForceDisconnectMessage("Server is using a different version of Mesen (" + EmulationSettings::GetMesenVersionString() + ") - you have been disconnected.");
|
SendForceDisconnectMessage("Server is using a different version of Mesen (" + EmulationSettings::GetMesenVersionString() + ") - you have been disconnected.");
|
||||||
MessageManager::DisplayMessage("NetPlay", + "NetplayVersionMismatch", message->GetPlayerName());
|
MessageManager::DisplayMessage("NetPlay", + "NetplayVersionMismatch", message->GetPlayerName());
|
||||||
|
@ -119,10 +144,16 @@ void GameServerConnection::ProcessMessage(NetMessage* message)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MessageType::InputData:
|
case MessageType::InputData:
|
||||||
|
if(_handshakeCompleted) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
PushState(((InputDataMessage*)message)->GetInputState());
|
PushState(((InputDataMessage*)message)->GetInputState());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MessageType::SelectController:
|
case MessageType::SelectController:
|
||||||
|
if(_handshakeCompleted) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
SelectControllerPort(((SelectControllerMessage*)message)->GetPortNumber());
|
SelectControllerPort(((SelectControllerMessage*)message)->GetPortNumber());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -208,11 +239,7 @@ uint8_t GameServerConnection::GetFirstFreeControllerPort()
|
||||||
|
|
||||||
string GameServerConnection::GetPlayerName()
|
string GameServerConnection::GetPlayerName()
|
||||||
{
|
{
|
||||||
if(_connectionData) {
|
return _playerName;
|
||||||
return _connectionData->PlayerName;
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GameServerConnection::GetControllerPort()
|
uint8_t GameServerConnection::GetControllerPort()
|
||||||
|
|
|
@ -15,10 +15,14 @@ private:
|
||||||
static GameServerConnection* _netPlayDevices[BaseControlDevice::PortCount];
|
static GameServerConnection* _netPlayDevices[BaseControlDevice::PortCount];
|
||||||
|
|
||||||
list<ControlDeviceState> _inputData;
|
list<ControlDeviceState> _inputData;
|
||||||
|
string _playerName;
|
||||||
int _controllerPort;
|
int _controllerPort;
|
||||||
|
string _connectionHash;
|
||||||
|
string _serverPassword;
|
||||||
bool _handshakeCompleted = false;
|
bool _handshakeCompleted = false;
|
||||||
|
|
||||||
void PushState(ControlDeviceState state);
|
void PushState(ControlDeviceState state);
|
||||||
|
void SendServerInformation();
|
||||||
void SendGameInformation();
|
void SendGameInformation();
|
||||||
void SelectControllerPort(uint8_t port);
|
void SelectControllerPort(uint8_t port);
|
||||||
|
|
||||||
|
@ -34,7 +38,7 @@ protected:
|
||||||
void ProcessMessage(NetMessage* message) override;
|
void ProcessMessage(NetMessage* message) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameServerConnection(shared_ptr<Socket> socket);
|
GameServerConnection(shared_ptr<Socket> socket, string serverPassword);
|
||||||
virtual ~GameServerConnection();
|
virtual ~GameServerConnection();
|
||||||
|
|
||||||
ControlDeviceState GetState();
|
ControlDeviceState GetState();
|
||||||
|
|
|
@ -2,15 +2,18 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "NetMessage.h"
|
#include "NetMessage.h"
|
||||||
#include "EmulationSettings.h"
|
#include "EmulationSettings.h"
|
||||||
|
#include "../Utilities/sha1.h"
|
||||||
|
|
||||||
class HandShakeMessage : public NetMessage
|
class HandShakeMessage : public NetMessage
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const static int CurrentVersion = 1;
|
const static int CurrentVersion = 2;
|
||||||
uint32_t _mesenVersion = 0;
|
uint32_t _mesenVersion = 0;
|
||||||
uint32_t _protocolVersion = CurrentVersion;
|
uint32_t _protocolVersion = CurrentVersion;
|
||||||
char* _playerName = nullptr;
|
char* _playerName = nullptr;
|
||||||
uint32_t _playerNameLength = 0;
|
uint32_t _playerNameLength = 0;
|
||||||
|
char* _hashedPassword = nullptr;
|
||||||
|
uint32_t _hashedPasswordLength = 0;
|
||||||
bool _spectator = false;
|
bool _spectator = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -19,16 +22,18 @@ protected:
|
||||||
Stream<uint32_t>(_mesenVersion);
|
Stream<uint32_t>(_mesenVersion);
|
||||||
Stream<uint32_t>(_protocolVersion);
|
Stream<uint32_t>(_protocolVersion);
|
||||||
StreamArray((void**)&_playerName, _playerNameLength);
|
StreamArray((void**)&_playerName, _playerNameLength);
|
||||||
|
StreamArray((void**)&_hashedPassword, _hashedPasswordLength);
|
||||||
Stream<bool>(_spectator);
|
Stream<bool>(_spectator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HandShakeMessage(void* buffer, uint32_t length) : NetMessage(buffer, length) { }
|
HandShakeMessage(void* buffer, uint32_t length) : NetMessage(buffer, length) {}
|
||||||
HandShakeMessage(string playerName, bool spectator) : NetMessage(MessageType::HandShake)
|
HandShakeMessage(string playerName, string hashedPassword, bool spectator) : NetMessage(MessageType::HandShake)
|
||||||
{
|
{
|
||||||
_mesenVersion = EmulationSettings::GetMesenVersion();
|
_mesenVersion = EmulationSettings::GetMesenVersion();
|
||||||
_protocolVersion = HandShakeMessage::CurrentVersion;
|
_protocolVersion = HandShakeMessage::CurrentVersion;
|
||||||
CopyString(&_playerName, _playerNameLength, playerName);
|
CopyString(&_playerName, _playerNameLength, playerName);
|
||||||
|
CopyString(&_hashedPassword, _hashedPasswordLength, hashedPassword);
|
||||||
_spectator = spectator;
|
_spectator = spectator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +47,20 @@ public:
|
||||||
return _protocolVersion == CurrentVersion && _mesenVersion == EmulationSettings::GetMesenVersion();
|
return _protocolVersion == CurrentVersion && _mesenVersion == EmulationSettings::GetMesenVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckPassword(string serverPassword, string connectionHash)
|
||||||
|
{
|
||||||
|
return GetPasswordHash(serverPassword, connectionHash) == string(_hashedPassword);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsSpectator()
|
bool IsSpectator()
|
||||||
{
|
{
|
||||||
return _spectator;
|
return _spectator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string GetPasswordHash(string serverPassword, string connectionHash)
|
||||||
|
{
|
||||||
|
string saltedPassword = serverPassword + connectionHash;
|
||||||
|
vector<uint8_t> dataToHash = vector<uint8_t>(saltedPassword.c_str(), saltedPassword.c_str() + saltedPassword.size());
|
||||||
|
return SHA1::GetHash(dataToHash);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,5 +10,6 @@ enum class MessageType : uint8_t
|
||||||
GameInformation = 4,
|
GameInformation = 4,
|
||||||
PlayerList = 5,
|
PlayerList = 5,
|
||||||
SelectController = 6,
|
SelectController = 6,
|
||||||
ForceDisconnect = 7
|
ForceDisconnect = 7,
|
||||||
|
ServerInformation = 8
|
||||||
};
|
};
|
28
Core/ServerInformationMessage.h
Normal file
28
Core/ServerInformationMessage.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "NetMessage.h"
|
||||||
|
|
||||||
|
class ServerInformationMessage : public NetMessage
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
char* _hashSalt = nullptr;
|
||||||
|
uint32_t _hashSaltLength = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void ProtectedStreamState()
|
||||||
|
{
|
||||||
|
StreamArray((void**)&_hashSalt, _hashSaltLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
ServerInformationMessage(void* buffer, uint32_t length) : NetMessage(buffer, length) {}
|
||||||
|
ServerInformationMessage(string hashSalt) : NetMessage(MessageType::ServerInformation)
|
||||||
|
{
|
||||||
|
CopyString(&_hashSalt, _hashSaltLength, hashSalt);
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetHashSalt()
|
||||||
|
{
|
||||||
|
return string(_hashSalt);
|
||||||
|
}
|
||||||
|
};
|
|
@ -10,6 +10,7 @@ namespace Mesen.GUI.Config
|
||||||
{
|
{
|
||||||
public string Host = "localhost";
|
public string Host = "localhost";
|
||||||
public UInt16 Port = 8888;
|
public UInt16 Port = 8888;
|
||||||
|
public string Password = "";
|
||||||
public bool Spectator = false;
|
public bool Spectator = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,6 @@ namespace Mesen.GUI.Config
|
||||||
{
|
{
|
||||||
public string Name = "Default";
|
public string Name = "Default";
|
||||||
public UInt16 Port = 8888;
|
public UInt16 Port = 8888;
|
||||||
public string Password = null;
|
public string Password = "";
|
||||||
public int MaxPlayers = 4;
|
|
||||||
public bool AllowSpectators = true;
|
|
||||||
public bool PublicServer = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,9 +159,9 @@ namespace Mesen.GUI.Controls
|
||||||
set { _minimum = value; SetValue(this.Value, true); }
|
set { _minimum = value; SetValue(this.Value, true); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal Increment { get; set; }
|
public decimal Increment { get; set; } = 1;
|
||||||
|
|
||||||
private int _decimalPlaces = 2;
|
private int _decimalPlaces = 0;
|
||||||
public int DecimalPlaces
|
public int DecimalPlaces
|
||||||
{
|
{
|
||||||
get { return _decimalPlaces; }
|
get { return _decimalPlaces; }
|
||||||
|
|
|
@ -440,6 +440,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Connexió a un servidor">
|
<Form ID="frmClientConfig" Title="Connexió a un servidor">
|
||||||
<Control ID="lblHost">Servidor:</Control>
|
<Control ID="lblHost">Servidor:</Control>
|
||||||
<Control ID="lblPort">Port:</Control>
|
<Control ID="lblPort">Port:</Control>
|
||||||
|
<Control ID="lblPassword">Contrasenya:</Control>
|
||||||
<Control ID="chkSpectator">Uneix-t'hi com a espectador</Control>
|
<Control ID="chkSpectator">Uneix-t'hi com a espectador</Control>
|
||||||
<Control ID="btnOK">D'acord</Control>
|
<Control ID="btnOK">D'acord</Control>
|
||||||
<Control ID="btnCancel">Cancel·la</Control>
|
<Control ID="btnCancel">Cancel·la</Control>
|
||||||
|
|
|
@ -441,6 +441,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Connect...">
|
<Form ID="frmClientConfig" Title="Connect...">
|
||||||
<Control ID="lblHost">Host:</Control>
|
<Control ID="lblHost">Host:</Control>
|
||||||
<Control ID="lblPort">Port:</Control>
|
<Control ID="lblPort">Port:</Control>
|
||||||
|
<Control ID="lblPassword">Password:</Control>
|
||||||
<Control ID="chkSpectator">Join as spectator</Control>
|
<Control ID="chkSpectator">Join as spectator</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">Cancel</Control>
|
<Control ID="btnCancel">Cancel</Control>
|
||||||
|
|
|
@ -438,6 +438,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Conexión a un servidor">
|
<Form ID="frmClientConfig" Title="Conexión a un servidor">
|
||||||
<Control ID="lblHost">Servidor host:</Control>
|
<Control ID="lblHost">Servidor host:</Control>
|
||||||
<Control ID="lblPort">Puerto:</Control>
|
<Control ID="lblPort">Puerto:</Control>
|
||||||
|
<Control ID="lblPassword">Contraseña:</Control>
|
||||||
<Control ID="chkSpectator">Unirse como espectador</Control>
|
<Control ID="chkSpectator">Unirse como espectador</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">Cancelar</Control>
|
<Control ID="btnCancel">Cancelar</Control>
|
||||||
|
|
|
@ -440,6 +440,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Connexion à un serveur">
|
<Form ID="frmClientConfig" Title="Connexion à un serveur">
|
||||||
<Control ID="lblHost">Serveur hôte:</Control>
|
<Control ID="lblHost">Serveur hôte:</Control>
|
||||||
<Control ID="lblPort">Port:</Control>
|
<Control ID="lblPort">Port:</Control>
|
||||||
|
<Control ID="lblPassword">Mot de passe:</Control>
|
||||||
<Control ID="chkSpectator">Se joindre en tant que spectateur</Control>
|
<Control ID="chkSpectator">Se joindre en tant que spectateur</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">Annuler</Control>
|
<Control ID="btnCancel">Annuler</Control>
|
||||||
|
|
|
@ -439,6 +439,7 @@
|
||||||
<Form ID="frmClientConfig" Title="サーバに接続">
|
<Form ID="frmClientConfig" Title="サーバに接続">
|
||||||
<Control ID="lblHost">ホスト:</Control>
|
<Control ID="lblHost">ホスト:</Control>
|
||||||
<Control ID="lblPort">ポート:</Control>
|
<Control ID="lblPort">ポート:</Control>
|
||||||
|
<Control ID="lblPassword">パスワード:</Control>
|
||||||
<Control ID="chkSpectator">観客として接続する</Control>
|
<Control ID="chkSpectator">観客として接続する</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">キャンセル</Control>
|
<Control ID="btnCancel">キャンセル</Control>
|
||||||
|
|
|
@ -436,6 +436,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Conexão a um servidor">
|
<Form ID="frmClientConfig" Title="Conexão a um servidor">
|
||||||
<Control ID="lblHost">Servidor host:</Control>
|
<Control ID="lblHost">Servidor host:</Control>
|
||||||
<Control ID="lblPort">Port:</Control>
|
<Control ID="lblPort">Port:</Control>
|
||||||
|
<Control ID="lblPassword">Senha:</Control>
|
||||||
<Control ID="chkSpectator">Entrar como espectador</Control>
|
<Control ID="chkSpectator">Entrar como espectador</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">Cancelar</Control>
|
<Control ID="btnCancel">Cancelar</Control>
|
||||||
|
|
|
@ -437,6 +437,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Подключение к серверу">
|
<Form ID="frmClientConfig" Title="Подключение к серверу">
|
||||||
<Control ID="lblHost">Имя сервера:</Control>
|
<Control ID="lblHost">Имя сервера:</Control>
|
||||||
<Control ID="lblPort">Порт:</Control>
|
<Control ID="lblPort">Порт:</Control>
|
||||||
|
<Control ID="lblPassword">Пароль:</Control>
|
||||||
<Control ID="chkSpectator">Войти как наблюдатель</Control>
|
<Control ID="chkSpectator">Войти как наблюдатель</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">Отмена</Control>
|
<Control ID="btnCancel">Отмена</Control>
|
||||||
|
|
|
@ -437,6 +437,7 @@
|
||||||
<Form ID="frmClientConfig" Title="Підключення до сервера">
|
<Form ID="frmClientConfig" Title="Підключення до сервера">
|
||||||
<Control ID="lblHost">Iм'я сервера:</Control>
|
<Control ID="lblHost">Iм'я сервера:</Control>
|
||||||
<Control ID="lblPort">Порт:</Control>
|
<Control ID="lblPort">Порт:</Control>
|
||||||
|
<Control ID="lblPassword">Пароль:</Control>
|
||||||
<Control ID="chkSpectator">Ввійти як спостерігач</Control>
|
<Control ID="chkSpectator">Ввійти як спостерігач</Control>
|
||||||
<Control ID="btnOK">OK</Control>
|
<Control ID="btnOK">OK</Control>
|
||||||
<Control ID="btnCancel">Вiдмiна</Control>
|
<Control ID="btnCancel">Вiдмiна</Control>
|
||||||
|
|
45
GUI.NET/Forms/NetPlay/frmClientConfig.Designer.cs
generated
45
GUI.NET/Forms/NetPlay/frmClientConfig.Designer.cs
generated
|
@ -33,12 +33,14 @@
|
||||||
this.lblPort = new System.Windows.Forms.Label();
|
this.lblPort = new System.Windows.Forms.Label();
|
||||||
this.txtHost = new System.Windows.Forms.TextBox();
|
this.txtHost = new System.Windows.Forms.TextBox();
|
||||||
this.chkSpectator = new System.Windows.Forms.CheckBox();
|
this.chkSpectator = new System.Windows.Forms.CheckBox();
|
||||||
|
this.lblPassword = new System.Windows.Forms.Label();
|
||||||
|
this.txtPassword = new System.Windows.Forms.TextBox();
|
||||||
this.tableLayoutPanel1.SuspendLayout();
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// baseConfigPanel
|
// baseConfigPanel
|
||||||
//
|
//
|
||||||
this.baseConfigPanel.Location = new System.Drawing.Point(0, 111);
|
this.baseConfigPanel.Location = new System.Drawing.Point(0, 110);
|
||||||
this.baseConfigPanel.Size = new System.Drawing.Size(290, 29);
|
this.baseConfigPanel.Size = new System.Drawing.Size(290, 29);
|
||||||
//
|
//
|
||||||
// tableLayoutPanel1
|
// tableLayoutPanel1
|
||||||
|
@ -46,28 +48,31 @@
|
||||||
this.tableLayoutPanel1.ColumnCount = 2;
|
this.tableLayoutPanel1.ColumnCount = 2;
|
||||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.txtPassword, 1, 2);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.txtPort, 1, 1);
|
this.tableLayoutPanel1.Controls.Add(this.txtPort, 1, 1);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.lblHost, 0, 0);
|
this.tableLayoutPanel1.Controls.Add(this.lblHost, 0, 0);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.lblPort, 0, 1);
|
this.tableLayoutPanel1.Controls.Add(this.lblPort, 0, 1);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.txtHost, 1, 0);
|
this.tableLayoutPanel1.Controls.Add(this.txtHost, 1, 0);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.chkSpectator, 0, 2);
|
this.tableLayoutPanel1.Controls.Add(this.chkSpectator, 0, 3);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.lblPassword, 0, 2);
|
||||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
this.tableLayoutPanel1.RowCount = 4;
|
this.tableLayoutPanel1.RowCount = 5;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(290, 111);
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(290, 110);
|
||||||
this.tableLayoutPanel1.TabIndex = 0;
|
this.tableLayoutPanel1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// txtPort
|
// txtPort
|
||||||
//
|
//
|
||||||
this.txtPort.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.txtPort.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.txtPort.Location = new System.Drawing.Point(41, 29);
|
this.txtPort.Location = new System.Drawing.Point(65, 29);
|
||||||
this.txtPort.Name = "txtPort";
|
this.txtPort.Name = "txtPort";
|
||||||
this.txtPort.Size = new System.Drawing.Size(246, 20);
|
this.txtPort.Size = new System.Drawing.Size(222, 20);
|
||||||
this.txtPort.TabIndex = 6;
|
this.txtPort.TabIndex = 6;
|
||||||
this.txtPort.TextChanged += new System.EventHandler(this.Field_TextChanged);
|
this.txtPort.TextChanged += new System.EventHandler(this.Field_TextChanged);
|
||||||
//
|
//
|
||||||
|
@ -94,9 +99,9 @@
|
||||||
// txtHost
|
// txtHost
|
||||||
//
|
//
|
||||||
this.txtHost.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.txtHost.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.txtHost.Location = new System.Drawing.Point(41, 3);
|
this.txtHost.Location = new System.Drawing.Point(65, 3);
|
||||||
this.txtHost.Name = "txtHost";
|
this.txtHost.Name = "txtHost";
|
||||||
this.txtHost.Size = new System.Drawing.Size(246, 20);
|
this.txtHost.Size = new System.Drawing.Size(222, 20);
|
||||||
this.txtHost.TabIndex = 5;
|
this.txtHost.TabIndex = 5;
|
||||||
this.txtHost.TextChanged += new System.EventHandler(this.Field_TextChanged);
|
this.txtHost.TextChanged += new System.EventHandler(this.Field_TextChanged);
|
||||||
//
|
//
|
||||||
|
@ -104,18 +109,36 @@
|
||||||
//
|
//
|
||||||
this.chkSpectator.AutoSize = true;
|
this.chkSpectator.AutoSize = true;
|
||||||
this.tableLayoutPanel1.SetColumnSpan(this.chkSpectator, 2);
|
this.tableLayoutPanel1.SetColumnSpan(this.chkSpectator, 2);
|
||||||
this.chkSpectator.Location = new System.Drawing.Point(3, 55);
|
this.chkSpectator.Location = new System.Drawing.Point(3, 81);
|
||||||
this.chkSpectator.Name = "chkSpectator";
|
this.chkSpectator.Name = "chkSpectator";
|
||||||
this.chkSpectator.Size = new System.Drawing.Size(106, 17);
|
this.chkSpectator.Size = new System.Drawing.Size(106, 17);
|
||||||
this.chkSpectator.TabIndex = 7;
|
this.chkSpectator.TabIndex = 7;
|
||||||
this.chkSpectator.Text = "Join as spectator";
|
this.chkSpectator.Text = "Join as spectator";
|
||||||
this.chkSpectator.UseVisualStyleBackColor = true;
|
this.chkSpectator.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// lblPassword
|
||||||
|
//
|
||||||
|
this.lblPassword.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||||
|
this.lblPassword.AutoSize = true;
|
||||||
|
this.lblPassword.Location = new System.Drawing.Point(3, 58);
|
||||||
|
this.lblPassword.Name = "lblPassword";
|
||||||
|
this.lblPassword.Size = new System.Drawing.Size(56, 13);
|
||||||
|
this.lblPassword.TabIndex = 8;
|
||||||
|
this.lblPassword.Text = "Password:";
|
||||||
|
//
|
||||||
|
// txtPassword
|
||||||
|
//
|
||||||
|
this.txtPassword.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.txtPassword.Location = new System.Drawing.Point(65, 55);
|
||||||
|
this.txtPassword.Name = "txtPassword";
|
||||||
|
this.txtPassword.Size = new System.Drawing.Size(222, 20);
|
||||||
|
this.txtPassword.TabIndex = 9;
|
||||||
|
//
|
||||||
// frmClientConfig
|
// frmClientConfig
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(290, 140);
|
this.ClientSize = new System.Drawing.Size(290, 139);
|
||||||
this.Controls.Add(this.tableLayoutPanel1);
|
this.Controls.Add(this.tableLayoutPanel1);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
|
@ -141,5 +164,7 @@
|
||||||
private System.Windows.Forms.Label lblPort;
|
private System.Windows.Forms.Label lblPort;
|
||||||
private System.Windows.Forms.TextBox txtHost;
|
private System.Windows.Forms.TextBox txtHost;
|
||||||
private System.Windows.Forms.CheckBox chkSpectator;
|
private System.Windows.Forms.CheckBox chkSpectator;
|
||||||
|
private System.Windows.Forms.TextBox txtPassword;
|
||||||
|
private System.Windows.Forms.Label lblPassword;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
Entity = ConfigManager.Config.ClientConnectionInfo;
|
Entity = ConfigManager.Config.ClientConnectionInfo;
|
||||||
|
|
||||||
AddBinding("Host", this.txtHost);
|
AddBinding("Host", this.txtHost);
|
||||||
|
AddBinding("Password", this.txtPassword);
|
||||||
AddBinding("Spectator", chkSpectator);
|
AddBinding("Spectator", chkSpectator);
|
||||||
this.txtPort.Text = ConfigManager.Config.ClientConnectionInfo.Port.ToString();
|
this.txtPort.Text = ConfigManager.Config.ClientConnectionInfo.Port.ToString();
|
||||||
}
|
}
|
||||||
|
|
97
GUI.NET/Forms/NetPlay/frmServerConfig.Designer.cs
generated
97
GUI.NET/Forms/NetPlay/frmServerConfig.Designer.cs
generated
|
@ -32,20 +32,16 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
this.tlpMain = new System.Windows.Forms.TableLayoutPanel();
|
this.tlpMain = new System.Windows.Forms.TableLayoutPanel();
|
||||||
this.txtPort = new System.Windows.Forms.TextBox();
|
this.txtPort = new System.Windows.Forms.TextBox();
|
||||||
this.lblPort = new System.Windows.Forms.Label();
|
this.lblPort = new System.Windows.Forms.Label();
|
||||||
this.chkPublicServer = new System.Windows.Forms.CheckBox();
|
|
||||||
this.lblServerName = new System.Windows.Forms.Label();
|
this.lblServerName = new System.Windows.Forms.Label();
|
||||||
this.txtServerName = new System.Windows.Forms.TextBox();
|
this.txtServerName = new System.Windows.Forms.TextBox();
|
||||||
this.chkSpectator = new System.Windows.Forms.CheckBox();
|
|
||||||
this.lblMaxPlayers = new System.Windows.Forms.Label();
|
|
||||||
this.lblPassword = new System.Windows.Forms.Label();
|
this.lblPassword = new System.Windows.Forms.Label();
|
||||||
this.txtPassword = new System.Windows.Forms.TextBox();
|
this.txtPassword = new System.Windows.Forms.TextBox();
|
||||||
this.nudNbPlayers = new MesenNumericUpDown();
|
|
||||||
this.tlpMain.SuspendLayout();
|
this.tlpMain.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// baseConfigPanel
|
// baseConfigPanel
|
||||||
//
|
//
|
||||||
this.baseConfigPanel.Location = new System.Drawing.Point(0, 161);
|
this.baseConfigPanel.Location = new System.Drawing.Point(0, 98);
|
||||||
this.baseConfigPanel.Size = new System.Drawing.Size(302, 29);
|
this.baseConfigPanel.Size = new System.Drawing.Size(302, 29);
|
||||||
//
|
//
|
||||||
// tlpMain
|
// tlpMain
|
||||||
|
@ -55,34 +51,28 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tlpMain.Controls.Add(this.txtPort, 1, 1);
|
this.tlpMain.Controls.Add(this.txtPort, 1, 1);
|
||||||
this.tlpMain.Controls.Add(this.lblPort, 0, 1);
|
this.tlpMain.Controls.Add(this.lblPort, 0, 1);
|
||||||
this.tlpMain.Controls.Add(this.chkPublicServer, 0, 4);
|
|
||||||
this.tlpMain.Controls.Add(this.lblServerName, 0, 0);
|
this.tlpMain.Controls.Add(this.lblServerName, 0, 0);
|
||||||
this.tlpMain.Controls.Add(this.txtServerName, 1, 0);
|
this.tlpMain.Controls.Add(this.txtServerName, 1, 0);
|
||||||
this.tlpMain.Controls.Add(this.chkSpectator, 0, 5);
|
|
||||||
this.tlpMain.Controls.Add(this.lblMaxPlayers, 0, 3);
|
|
||||||
this.tlpMain.Controls.Add(this.lblPassword, 0, 2);
|
this.tlpMain.Controls.Add(this.lblPassword, 0, 2);
|
||||||
this.tlpMain.Controls.Add(this.txtPassword, 1, 2);
|
this.tlpMain.Controls.Add(this.txtPassword, 1, 2);
|
||||||
this.tlpMain.Controls.Add(this.nudNbPlayers, 1, 3);
|
|
||||||
this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tlpMain.Location = new System.Drawing.Point(0, 0);
|
this.tlpMain.Location = new System.Drawing.Point(0, 0);
|
||||||
this.tlpMain.Name = "tlpMain";
|
this.tlpMain.Name = "tlpMain";
|
||||||
this.tlpMain.RowCount = 7;
|
this.tlpMain.RowCount = 4;
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
this.tlpMain.Size = new System.Drawing.Size(302, 161);
|
this.tlpMain.Size = new System.Drawing.Size(302, 98);
|
||||||
this.tlpMain.TabIndex = 1;
|
this.tlpMain.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// txtPort
|
// txtPort
|
||||||
//
|
//
|
||||||
this.txtPort.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.txtPort.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.txtPort.Location = new System.Drawing.Point(128, 29);
|
this.txtPort.Location = new System.Drawing.Point(79, 29);
|
||||||
this.txtPort.Name = "txtPort";
|
this.txtPort.Name = "txtPort";
|
||||||
this.txtPort.Size = new System.Drawing.Size(171, 20);
|
this.txtPort.Size = new System.Drawing.Size(220, 20);
|
||||||
this.txtPort.TabIndex = 13;
|
this.txtPort.TabIndex = 13;
|
||||||
this.txtPort.TextChanged += new System.EventHandler(this.Field_ValueChanged);
|
this.txtPort.TextChanged += new System.EventHandler(this.Field_ValueChanged);
|
||||||
//
|
//
|
||||||
|
@ -96,19 +86,6 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
this.lblPort.TabIndex = 12;
|
this.lblPort.TabIndex = 12;
|
||||||
this.lblPort.Text = "Port:";
|
this.lblPort.Text = "Port:";
|
||||||
//
|
//
|
||||||
// chkPublicServer
|
|
||||||
//
|
|
||||||
this.chkPublicServer.AutoSize = true;
|
|
||||||
this.tlpMain.SetColumnSpan(this.chkPublicServer, 2);
|
|
||||||
this.chkPublicServer.Enabled = false;
|
|
||||||
this.chkPublicServer.Location = new System.Drawing.Point(3, 107);
|
|
||||||
this.chkPublicServer.Name = "chkPublicServer";
|
|
||||||
this.chkPublicServer.Size = new System.Drawing.Size(87, 17);
|
|
||||||
this.chkPublicServer.TabIndex = 11;
|
|
||||||
this.chkPublicServer.Text = "Public server";
|
|
||||||
this.chkPublicServer.UseVisualStyleBackColor = true;
|
|
||||||
this.chkPublicServer.CheckedChanged += new System.EventHandler(this.Field_ValueChanged);
|
|
||||||
//
|
|
||||||
// lblServerName
|
// lblServerName
|
||||||
//
|
//
|
||||||
this.lblServerName.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
this.lblServerName.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||||
|
@ -122,35 +99,12 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
// txtServerName
|
// txtServerName
|
||||||
//
|
//
|
||||||
this.txtServerName.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.txtServerName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.txtServerName.Location = new System.Drawing.Point(128, 3);
|
this.txtServerName.Location = new System.Drawing.Point(79, 3);
|
||||||
this.txtServerName.Name = "txtServerName";
|
this.txtServerName.Name = "txtServerName";
|
||||||
this.txtServerName.Size = new System.Drawing.Size(171, 20);
|
this.txtServerName.Size = new System.Drawing.Size(220, 20);
|
||||||
this.txtServerName.TabIndex = 5;
|
this.txtServerName.TabIndex = 5;
|
||||||
this.txtServerName.TextChanged += new System.EventHandler(this.Field_ValueChanged);
|
this.txtServerName.TextChanged += new System.EventHandler(this.Field_ValueChanged);
|
||||||
//
|
//
|
||||||
// chkSpectator
|
|
||||||
//
|
|
||||||
this.chkSpectator.AutoSize = true;
|
|
||||||
this.tlpMain.SetColumnSpan(this.chkSpectator, 2);
|
|
||||||
this.chkSpectator.Enabled = false;
|
|
||||||
this.chkSpectator.Location = new System.Drawing.Point(3, 130);
|
|
||||||
this.chkSpectator.Name = "chkSpectator";
|
|
||||||
this.chkSpectator.Size = new System.Drawing.Size(103, 17);
|
|
||||||
this.chkSpectator.TabIndex = 7;
|
|
||||||
this.chkSpectator.Text = "Allow spectators";
|
|
||||||
this.chkSpectator.UseVisualStyleBackColor = true;
|
|
||||||
this.chkSpectator.CheckedChanged += new System.EventHandler(this.Field_ValueChanged);
|
|
||||||
//
|
|
||||||
// lblMaxPlayers
|
|
||||||
//
|
|
||||||
this.lblMaxPlayers.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
|
||||||
this.lblMaxPlayers.AutoSize = true;
|
|
||||||
this.lblMaxPlayers.Location = new System.Drawing.Point(3, 84);
|
|
||||||
this.lblMaxPlayers.Name = "lblMaxPlayers";
|
|
||||||
this.lblMaxPlayers.Size = new System.Drawing.Size(119, 13);
|
|
||||||
this.lblMaxPlayers.TabIndex = 4;
|
|
||||||
this.lblMaxPlayers.Text = "Max. number of players:";
|
|
||||||
//
|
|
||||||
// lblPassword
|
// lblPassword
|
||||||
//
|
//
|
||||||
this.lblPassword.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
this.lblPassword.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||||
|
@ -164,43 +118,18 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
// txtPassword
|
// txtPassword
|
||||||
//
|
//
|
||||||
this.txtPassword.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.txtPassword.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.txtPassword.Enabled = false;
|
this.txtPassword.Location = new System.Drawing.Point(79, 55);
|
||||||
this.txtPassword.Location = new System.Drawing.Point(128, 55);
|
|
||||||
this.txtPassword.Name = "txtPassword";
|
this.txtPassword.Name = "txtPassword";
|
||||||
this.txtPassword.Size = new System.Drawing.Size(171, 20);
|
this.txtPassword.Size = new System.Drawing.Size(220, 20);
|
||||||
this.txtPassword.TabIndex = 10;
|
this.txtPassword.TabIndex = 10;
|
||||||
this.txtPassword.UseSystemPasswordChar = true;
|
this.txtPassword.UseSystemPasswordChar = true;
|
||||||
this.txtPassword.TextChanged += new System.EventHandler(this.Field_ValueChanged);
|
this.txtPassword.TextChanged += new System.EventHandler(this.Field_ValueChanged);
|
||||||
//
|
//
|
||||||
// nudNbPlayers
|
|
||||||
//
|
|
||||||
this.nudNbPlayers.Enabled = false;
|
|
||||||
this.nudNbPlayers.Location = new System.Drawing.Point(128, 81);
|
|
||||||
this.nudNbPlayers.Maximum = new decimal(new int[] {
|
|
||||||
4,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.nudNbPlayers.Minimum = new decimal(new int[] {
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.nudNbPlayers.Name = "nudNbPlayers";
|
|
||||||
this.nudNbPlayers.Size = new System.Drawing.Size(35, 20);
|
|
||||||
this.nudNbPlayers.TabIndex = 8;
|
|
||||||
this.nudNbPlayers.Value = new decimal(new int[] {
|
|
||||||
4,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.nudNbPlayers.ValueChanged += new System.EventHandler(this.Field_ValueChanged);
|
|
||||||
//
|
|
||||||
// frmServerConfig
|
// frmServerConfig
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(302, 190);
|
this.ClientSize = new System.Drawing.Size(302, 127);
|
||||||
this.Controls.Add(this.tlpMain);
|
this.Controls.Add(this.tlpMain);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
|
@ -220,11 +149,7 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
|
|
||||||
private System.Windows.Forms.TableLayoutPanel tlpMain;
|
private System.Windows.Forms.TableLayoutPanel tlpMain;
|
||||||
private System.Windows.Forms.Label lblServerName;
|
private System.Windows.Forms.Label lblServerName;
|
||||||
private System.Windows.Forms.Label lblMaxPlayers;
|
|
||||||
private System.Windows.Forms.TextBox txtServerName;
|
private System.Windows.Forms.TextBox txtServerName;
|
||||||
private System.Windows.Forms.CheckBox chkSpectator;
|
|
||||||
private MesenNumericUpDown nudNbPlayers;
|
|
||||||
private System.Windows.Forms.CheckBox chkPublicServer;
|
|
||||||
private System.Windows.Forms.Label lblPassword;
|
private System.Windows.Forms.Label lblPassword;
|
||||||
private System.Windows.Forms.TextBox txtPassword;
|
private System.Windows.Forms.TextBox txtPassword;
|
||||||
private System.Windows.Forms.Label lblPort;
|
private System.Windows.Forms.Label lblPort;
|
||||||
|
|
|
@ -20,9 +20,6 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
this.txtServerName.Text = ConfigManager.Config.ServerInfo.Name;
|
this.txtServerName.Text = ConfigManager.Config.ServerInfo.Name;
|
||||||
this.txtPort.Text = ConfigManager.Config.ServerInfo.Port.ToString();
|
this.txtPort.Text = ConfigManager.Config.ServerInfo.Port.ToString();
|
||||||
this.txtPassword.Text = string.Empty;
|
this.txtPassword.Text = string.Empty;
|
||||||
this.nudNbPlayers.Value = ConfigManager.Config.ServerInfo.MaxPlayers;
|
|
||||||
this.chkSpectator.Checked = ConfigManager.Config.ServerInfo.AllowSpectators;
|
|
||||||
this.chkPublicServer.Checked = ConfigManager.Config.ServerInfo.PublicServer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateConfig()
|
protected override void UpdateConfig()
|
||||||
|
@ -30,10 +27,7 @@ namespace Mesen.GUI.Forms.NetPlay
|
||||||
ConfigManager.Config.ServerInfo = new ServerInfo() {
|
ConfigManager.Config.ServerInfo = new ServerInfo() {
|
||||||
Name = this.txtServerName.Text,
|
Name = this.txtServerName.Text,
|
||||||
Port = Convert.ToUInt16(this.txtPort.Text),
|
Port = Convert.ToUInt16(this.txtPort.Text),
|
||||||
Password = BitConverter.ToString(System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(this.txtPassword.Text))).Replace("-", ""),
|
Password = this.txtPassword.Text
|
||||||
MaxPlayers = (int)this.nudNbPlayers.Value,
|
|
||||||
AllowSpectators = this.chkSpectator.Checked,
|
|
||||||
PublicServer = this.chkPublicServer.Checked
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace Mesen.GUI.Forms
|
||||||
} else {
|
} else {
|
||||||
using(frmServerConfig frm = new frmServerConfig()) {
|
using(frmServerConfig frm = new frmServerConfig()) {
|
||||||
if(frm.ShowDialog(sender, this) == System.Windows.Forms.DialogResult.OK) {
|
if(frm.ShowDialog(sender, this) == System.Windows.Forms.DialogResult.OK) {
|
||||||
InteropEmu.StartServer(ConfigManager.Config.ServerInfo.Port, ConfigManager.Config.Profile.PlayerName);
|
InteropEmu.StartServer(ConfigManager.Config.ServerInfo.Port, ConfigManager.Config.ServerInfo.Password, ConfigManager.Config.Profile.PlayerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,13 @@ namespace Mesen.GUI.Forms
|
||||||
using(frmClientConfig frm = new frmClientConfig()) {
|
using(frmClientConfig frm = new frmClientConfig()) {
|
||||||
if(frm.ShowDialog(sender, this) == System.Windows.Forms.DialogResult.OK) {
|
if(frm.ShowDialog(sender, this) == System.Windows.Forms.DialogResult.OK) {
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
InteropEmu.Connect(ConfigManager.Config.ClientConnectionInfo.Host, ConfigManager.Config.ClientConnectionInfo.Port, ConfigManager.Config.Profile.PlayerName, ConfigManager.Config.ClientConnectionInfo.Spectator);
|
InteropEmu.Connect(
|
||||||
|
ConfigManager.Config.ClientConnectionInfo.Host,
|
||||||
|
ConfigManager.Config.ClientConnectionInfo.Port,
|
||||||
|
ConfigManager.Config.ClientConnectionInfo.Password,
|
||||||
|
ConfigManager.Config.Profile.PlayerName,
|
||||||
|
ConfigManager.Config.ClientConnectionInfo.Spectator
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,10 @@ namespace Mesen.GUI
|
||||||
[DllImport(DLLPath)] public static extern void Reset();
|
[DllImport(DLLPath)] public static extern void Reset();
|
||||||
[DllImport(DLLPath)] public static extern void ResetLagCounter();
|
[DllImport(DLLPath)] public static extern void ResetLagCounter();
|
||||||
|
|
||||||
[DllImport(DLLPath)] public static extern void StartServer(UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string hostPlayerName);
|
[DllImport(DLLPath)] public static extern void StartServer(UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string password, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string hostPlayerName);
|
||||||
[DllImport(DLLPath)] public static extern void StopServer();
|
[DllImport(DLLPath)] public static extern void StopServer();
|
||||||
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsServerRunning();
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsServerRunning();
|
||||||
[DllImport(DLLPath)] public static extern void Connect([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string host, UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string playerName, [MarshalAs(UnmanagedType.I1)]bool spectator);
|
[DllImport(DLLPath)] public static extern void Connect([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string host, UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string password, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string playerName, [MarshalAs(UnmanagedType.I1)]bool spectator);
|
||||||
[DllImport(DLLPath)] public static extern void Disconnect();
|
[DllImport(DLLPath)] public static extern void Disconnect();
|
||||||
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsConnected();
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsConnected();
|
||||||
|
|
||||||
|
|
|
@ -262,19 +262,13 @@ namespace InteropEmu {
|
||||||
DllExport void __stdcall PowerCycle() { Console::Reset(false); }
|
DllExport void __stdcall PowerCycle() { Console::Reset(false); }
|
||||||
DllExport void __stdcall ResetLagCounter() { Console::ResetLagCounter(); }
|
DllExport void __stdcall ResetLagCounter() { Console::ResetLagCounter(); }
|
||||||
|
|
||||||
DllExport void __stdcall StartServer(uint16_t port, char* hostPlayerName) { GameServer::StartServer(port, hostPlayerName); }
|
DllExport void __stdcall StartServer(uint16_t port, char* password, char* hostPlayerName) { GameServer::StartServer(port, password, hostPlayerName); }
|
||||||
DllExport void __stdcall StopServer() { GameServer::StopServer(); }
|
DllExport void __stdcall StopServer() { GameServer::StopServer(); }
|
||||||
DllExport bool __stdcall IsServerRunning() { return GameServer::Started(); }
|
DllExport bool __stdcall IsServerRunning() { return GameServer::Started(); }
|
||||||
|
|
||||||
DllExport void __stdcall Connect(char* host, uint16_t port, char* playerName, bool spectator)
|
DllExport void __stdcall Connect(char* host, uint16_t port, char* password, char* playerName, bool spectator)
|
||||||
{
|
{
|
||||||
shared_ptr<ClientConnectionData> connectionData(new ClientConnectionData(
|
ClientConnectionData connectionData(host, port, password, playerName, spectator);
|
||||||
host,
|
|
||||||
port,
|
|
||||||
playerName,
|
|
||||||
spectator
|
|
||||||
));
|
|
||||||
|
|
||||||
GameClient::Connect(connectionData);
|
GameClient::Connect(connectionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue