Added a class that client and server inherits from.
Class and server now share the same pointer i game. You are now able to start a client and a server on the same computer.
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Network/Network.h"
|
||||
|
||||
|
||||
class Client
|
||||
class Client : public Network
|
||||
{
|
||||
public:
|
||||
Client();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef Network_h__
|
||||
#define Network_h__
|
||||
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Network/Package.h"
|
||||
|
||||
class Network
|
||||
{
|
||||
public:
|
||||
Network();
|
||||
~Network();
|
||||
virtual void Start(World* m_world, EventBroker *eventBroker);
|
||||
virtual void Update();
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -14,8 +14,9 @@
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/ECreatePlayer.h"
|
||||
#include "Network/Network.h"
|
||||
|
||||
class Server
|
||||
class Server : public Network
|
||||
{
|
||||
public:
|
||||
Server();
|
||||
|
||||
+3
-3
@@ -21,6 +21,7 @@
|
||||
|
||||
// Network
|
||||
#include <boost/thread.hpp>
|
||||
#include "Network/Network.h"
|
||||
#include "Network/Server.h"
|
||||
#include "Network/Client.h"
|
||||
|
||||
@@ -50,9 +51,8 @@ private:
|
||||
|
||||
// Network methods
|
||||
void NetworkFunction();
|
||||
Client m_Client;
|
||||
Server m_Server;
|
||||
bool m_IsClient = false;
|
||||
Network* m_ClientOrServer;
|
||||
bool m_IsClientOrServer = false;
|
||||
|
||||
EventRelay<Game, Events::InputCommand> m_EInputCommand;
|
||||
bool debugOnInputCommand(const Events::InputCommand& e);
|
||||
|
||||
Reference in New Issue
Block a user