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:
@@ -13,31 +13,42 @@ class JSocket;
|
||||
#include <sstream>
|
||||
#include "Threading.h"
|
||||
|
||||
typedef void(*processCmd)(istream&, ostream&);
|
||||
typedef void(*processCmd)(void*, stringstream&, stringstream&);
|
||||
|
||||
class JNetwork {
|
||||
private:
|
||||
struct CommandStruc{
|
||||
void* object;
|
||||
string command;
|
||||
processCmd processCommand;
|
||||
};
|
||||
|
||||
string serverIP;
|
||||
int connected_to_ap;
|
||||
JSocket* socket;
|
||||
boost::mutex sendMutex;
|
||||
boost::mutex receiveMutex;
|
||||
stringstream received;
|
||||
stringstream toSend;
|
||||
static map<string, processCmd> sCommandMap;
|
||||
static map<string, CommandStruc> sCommandMap;
|
||||
static JNetwork* mInstance;
|
||||
|
||||
public:
|
||||
JNetwork();
|
||||
~JNetwork();
|
||||
string serverIP;
|
||||
static JNetwork* GetInstance();
|
||||
static void Destroy();
|
||||
void Update();
|
||||
|
||||
int connect(string serverIP = "");
|
||||
bool isConnected();
|
||||
bool isServer() { return serverIP == ""; };
|
||||
static void ThreadProc(void* param);
|
||||
#if !defined (WIN32) && !defined (LINUX)
|
||||
static int connect_to_apctl(int config);
|
||||
#endif
|
||||
bool sendCommand(string command);
|
||||
static void registerCommand(string command, processCmd processCommand, processCmd processResponse);
|
||||
bool sendCommand(const string& command, const string& payload = "", const string& suffix = "Request");
|
||||
static void registerCommand(string command, void* object, processCmd processRequest, processCmd processResponse);
|
||||
|
||||
private:
|
||||
boost::thread *mpWorkerThread;
|
||||
|
||||
Reference in New Issue
Block a user