Created a NetworkGameObserver class able to extend the serialization code of GameObserver to synchronize and forward game actions on the network

Fixes in GameObserver serialization/deserialization code
Fixes in JNetwork and JSocket on windows
Various code cleanup (currentGamePhase access in particular)
Updated GUI code to re-enable a basic network GUI
Activated threaded tests on Windows. It uses 4 threads by default.
This commit is contained in:
Xawotihs@gmail.com
2013-01-22 22:39:49 +00:00
parent ada0a1555d
commit 9db8478dfe
18 changed files with 493 additions and 269 deletions

View File

@@ -1,3 +1,4 @@
#include "PrecompiledHeader.h"
#include "NetworkPlayer.h"
#include <sstream>
@@ -10,14 +11,14 @@ void RegisterNetworkPlayers()
}
RemotePlayer::RemotePlayer(JNetwork* pxNetwork)
: Player("remote", "", NULL), mpNetwork(pxNetwork)
RemotePlayer::RemotePlayer(GameObserver* observer, JNetwork* pxNetwork)
: Player(observer, "remote", "", NULL), mpNetwork(pxNetwork)
{
mInstance = this;
mpNetwork->sendCommand("GetPlayer");
}
void RemotePlayer::Deserialize(istream& in, ostream& out)
void RemotePlayer::Deserialize(void*, stringstream& in, stringstream& out)
{
// istringstream ss(mInstance->mpNetwork->receiveString());
in >> *mInstance;
@@ -28,14 +29,14 @@ ProxyPlayer::ProxyPlayer(Player* pxPlayer, JNetwork* pxNetwork)
: mpPlayer(pxPlayer), mpNetwork(pxNetwork)
{
mInstance = this;
JNetwork::registerCommand("GetPlayer", ProxyPlayer::Serialize, RemotePlayer::Deserialize);
JNetwork::registerCommand("GetPlayer", this, ProxyPlayer::Serialize, RemotePlayer::Deserialize);
// ostringstream ss;
// ss << "Player : " << *mpPlayer;
// mpNetwork->send(ss.str());
}
void ProxyPlayer::Serialize(istream& in, ostream& out)
void ProxyPlayer::Serialize(void*, stringstream& in, stringstream& out)
{
out << *(mInstance->mpPlayer);
}