Client now reads address and port from config file. Default address is set to local host.

This commit is contained in:
stiffly
2015-12-18 11:22:13 +01:00
parent 0b714e593f
commit 5c1a93021b
4 changed files with 11 additions and 8 deletions
+3 -2
View File
@@ -6,19 +6,20 @@
#include <glm/common.hpp> #include <glm/common.hpp>
#include "Network/Network.h"
#include "Network/MessageType.h" #include "Network/MessageType.h"
#include "Network/NetworkDefinitions.h" #include "Network/NetworkDefinitions.h"
#include "Network/PlayerDefinition.h" #include "Network/PlayerDefinition.h"
#include "Network/SnapshotDefinitions.h" #include "Network/SnapshotDefinitions.h"
#include "Core/World.h" #include "Core/World.h"
#include "Core/EventBroker.h" #include "Core/EventBroker.h"
#include "Core/ConfigFile.h"
#include "Input/EInputCommand.h" #include "Input/EInputCommand.h"
#include "Network/Network.h"
class Client : public Network class Client : public Network
{ {
public: public:
Client(); Client(ConfigFile* config);
~Client(); ~Client();
void Start(World* world, EventBroker* eventBroker); void Start(World* world, EventBroker* eventBroker);
void Update(); void Update();
+2 -3
View File
@@ -1,5 +1,4 @@
[Debug] [Debug]
LogLevel=1 LogLevel=1
LoadMap= LoadMap=
EditorEnabled=false EditorEnabled=false
@@ -13,5 +12,5 @@ Height=720
FOV=45 FOV=45
[Networking] [Networking]
StartNetwork=false StartNetwork=false
Address=0.0.0.0 Address=127.0.0.1
Port=0 Port=13
+5 -2
View File
@@ -3,9 +3,12 @@
using namespace boost::asio::ip; using namespace boost::asio::ip;
Client::Client() : m_Socket(m_IOService) Client::Client(ConfigFile* config) : m_Socket(m_IOService)
{ {
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address::from_string("192.168.1.2"), 13); // Default is local host
std::string address = config->Get<std::string>("Networking.Address", "127.0.0.1");
int port = config->Get<int>("Networking.Port", 13);
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address::from_string(address), port);
// Set up network stream // Set up network stream
m_NextSnapshot.InputForward = ""; m_NextSnapshot.InputForward = "";
m_NextSnapshot.InputRight = ""; m_NextSnapshot.InputRight = "";
+1 -1
View File
@@ -143,7 +143,7 @@ void Game::networkFunction()
std::cin >> inputMessage; std::cin >> inputMessage;
if (inputMessage == "c" || inputMessage == "C") { if (inputMessage == "c" || inputMessage == "C") {
m_IsClientOrServer = true; m_IsClientOrServer = true;
m_ClientOrServer = new Client(); m_ClientOrServer = new Client(m_Config);
} }
if (inputMessage == "s" || inputMessage == "S") { if (inputMessage == "s" || inputMessage == "S") {
m_IsClientOrServer = true; m_IsClientOrServer = true;