Network now runs on it's own thread.
Network now sends Disconnect message when game is terminated.
This commit is contained in:
@@ -18,6 +18,7 @@ public:
|
||||
Client();
|
||||
~Client();
|
||||
void Start();
|
||||
void Close();
|
||||
|
||||
private:
|
||||
// Threaded
|
||||
@@ -27,6 +28,7 @@ private:
|
||||
|
||||
int Receive(char* data, size_t length);
|
||||
int CreateMessage(MessageType type, std::string message, char* data);
|
||||
void Disconnect();
|
||||
void MoveMessageHead(char*& data, size_t& length, size_t stepSize);
|
||||
void ParseMessageType(char* data, size_t length);
|
||||
void ParseEventMessage(char* data, size_t length);
|
||||
@@ -51,6 +53,7 @@ private:
|
||||
double m_DurationOfPingTime;
|
||||
bool m_ShouldDrawGameBoard = true;
|
||||
std::string m_PlayerName;
|
||||
bool m_ThreadIsRunning = true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "Core/InputManager.h"
|
||||
#include "GUI/Frame.h"
|
||||
#include "Core/World.h"
|
||||
// Network
|
||||
#include <boost/thread.hpp>
|
||||
#include "Network/Client.h"
|
||||
|
||||
class Game
|
||||
{
|
||||
@@ -26,6 +29,13 @@ private:
|
||||
InputManager* m_InputManager;
|
||||
GUI::Frame* m_FrameStack;
|
||||
World* m_World;
|
||||
// Network viriables
|
||||
boost::thread m_NetworkThread;
|
||||
Client m_Client;
|
||||
|
||||
// Network methods
|
||||
void NetworkFunction();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user