Cleaned up Network code (hope that fixes the PSP compilation problems)

Added random seed logging
This commit is contained in:
Xawotihs@gmail.com
2013-01-25 21:47:16 +00:00
parent 4bf419fbaf
commit 2ba5eb0022
10 changed files with 39 additions and 56 deletions

View File

@@ -17,6 +17,8 @@ typedef void(*processCmd)(void*, stringstream&, stringstream&);
class JNetwork {
private:
private:
boost::thread *mpWorkerThread;
struct CommandStruc{
void* object;
string command;
@@ -31,13 +33,10 @@ private:
stringstream received;
stringstream toSend;
static map<string, CommandStruc> sCommandMap;
static JNetwork* mInstance;
public:
JNetwork();
~JNetwork();
static JNetwork* GetInstance();
static void Destroy();
void Update();
int connect(string serverIP = "");
@@ -49,9 +48,6 @@ public:
#endif
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;
};
#endif

View File

@@ -32,6 +32,8 @@ public:
void Disconnect();
private:
// socket state
SOCKET_STATE state;
// socket creation when server accepts a connection
JSocket(int fd);
// convert the socket into non-blocking state
@@ -42,8 +44,6 @@ private:
#elif LINUX
int mfd;
#endif
// socket state
SOCKET_STATE state;
};
#endif

View File

@@ -34,7 +34,6 @@
#include "../include/JSocket.h"
map<string, JNetwork::CommandStruc> JNetwork::sCommandMap;
JNetwork* JNetwork::mInstance = NULL;
bool JNetwork::isConnected(){
if (connected_to_ap !=1 || !socket) return false;
@@ -63,21 +62,6 @@ JNetwork::~JNetwork()
delete socket;
}
JNetwork* JNetwork::GetInstance()
{
if (mInstance == NULL) mInstance = new JNetwork();
return mInstance;
}
void JNetwork::Destroy()
{
if (mInstance)
{
delete mInstance;
mInstance = NULL;
}
}
bool JNetwork::sendCommand(const string& xString, const string& payload, const string& suffix)
{
string aString;