Client now reads address and port from config file. Default address is set to local host.
This commit is contained in:
@@ -6,19 +6,20 @@
|
||||
|
||||
#include <glm/common.hpp>
|
||||
|
||||
#include "Network/Network.h"
|
||||
#include "Network/MessageType.h"
|
||||
#include "Network/NetworkDefinitions.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
#include "Network/SnapshotDefinitions.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Network/Network.h"
|
||||
|
||||
class Client : public Network
|
||||
{
|
||||
public:
|
||||
Client();
|
||||
Client(ConfigFile* config);
|
||||
~Client();
|
||||
void Start(World* world, EventBroker* eventBroker);
|
||||
void Update();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
[Debug]
|
||||
|
||||
LogLevel=1
|
||||
LoadMap=
|
||||
EditorEnabled=false
|
||||
@@ -13,5 +12,5 @@ Height=720
|
||||
FOV=45
|
||||
[Networking]
|
||||
StartNetwork=false
|
||||
Address=0.0.0.0
|
||||
Port=0
|
||||
Address=127.0.0.1
|
||||
Port=13
|
||||
@@ -3,9 +3,12 @@
|
||||
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
|
||||
m_NextSnapshot.InputForward = "";
|
||||
m_NextSnapshot.InputRight = "";
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ void Game::networkFunction()
|
||||
std::cin >> inputMessage;
|
||||
if (inputMessage == "c" || inputMessage == "C") {
|
||||
m_IsClientOrServer = true;
|
||||
m_ClientOrServer = new Client();
|
||||
m_ClientOrServer = new Client(m_Config);
|
||||
}
|
||||
if (inputMessage == "s" || inputMessage == "S") {
|
||||
m_IsClientOrServer = true;
|
||||
|
||||
Reference in New Issue
Block a user