Files
wagic/projects/mtg/src/NetworkPlayer.cpp
Xawotihs@gmail.com 9db8478dfe 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.
2013-01-22 22:39:49 +00:00

43 lines
1.1 KiB
C++

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