Network now runs on it's own thread.

Network now sends Disconnect message when game is terminated.
This commit is contained in:
Jocke
2015-12-08 11:02:40 +01:00
parent 2c993e82d6
commit b5a010a517
4 changed files with 45 additions and 16 deletions
+12 -8
View File
@@ -1,6 +1,5 @@
#include "Game.h"
#include "HardcodedTestWorld.h"
#include "Network/Client.h"
Game::Game(int argc, char* argv[])
{
@@ -38,13 +37,7 @@ Game::Game(int argc, char* argv[])
m_World = new HardcodedTestWorld();
// TEMP: Invoke network
std::string inputMessage;
std::cout << "Start client or server? (c/s)" << std::endl;
std::cin >> inputMessage;
if (inputMessage == "c" || inputMessage == "C") {
Client client;
client.Start();
}
boost::thread workerThread(&Game::NetworkFunction, this);
m_LastTime = glfwGetTime();
}
@@ -53,6 +46,7 @@ Game::~Game()
{
delete m_FrameStack;
delete m_EventBroker;
m_Client.Close();
}
void Game::Tick()
@@ -75,3 +69,13 @@ void Game::Tick()
glfwPollEvents();
}
void Game::NetworkFunction()
{
std::string inputMessage;
std::cout << "Start client or server? (c/s)" << std::endl;
std::cin >> inputMessage;
if (inputMessage == "c" || inputMessage == "C") {
m_Client.Start();
}
}