Completely removed MainServer code. All server code is now part of the program
This commit is contained in:
parent
0b67c9cc46
commit
26d807ce87
31 changed files with 459 additions and 512 deletions
|
|
@ -1,16 +1,10 @@
|
|||
#include "ConnectionManager.hpp"
|
||||
#include "Helpers/Networking/NetLibrary.hpp"
|
||||
#include "Server/CommandList.hpp"
|
||||
#include "CommandList.hpp"
|
||||
#include <chrono>
|
||||
#include "World.hpp"
|
||||
#include <Helpers/Logger.hpp>
|
||||
|
||||
void ConnectionManager::init_local_p2p(World& initWorld, const std::string& serverLocalID) {
|
||||
localServer = std::make_unique<MainServer>(initWorld, serverLocalID);
|
||||
client = std::make_shared<NetClient>(*localServer->netServer);
|
||||
lastKeepAliveTime = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
void ConnectionManager::connect_p2p(World& initWorld, const std::string& serverFullID) {
|
||||
client = std::make_shared<NetClient>(serverFullID);
|
||||
lastKeepAliveTime = std::chrono::steady_clock::now();
|
||||
|
|
@ -19,9 +13,6 @@ void ConnectionManager::connect_p2p(World& initWorld, const std::string& serverF
|
|||
}
|
||||
|
||||
void ConnectionManager::update() {
|
||||
if(localServer) {
|
||||
localServer->update();
|
||||
}
|
||||
if(client) {
|
||||
client->update();
|
||||
if(std::chrono::steady_clock::now() - lastKeepAliveTime > std::chrono::seconds(2)) {
|
||||
|
|
@ -40,14 +31,6 @@ bool ConnectionManager::is_client_disconnected() {
|
|||
return client && client->is_disconnected();
|
||||
}
|
||||
|
||||
bool ConnectionManager::is_host_disconnected() {
|
||||
return localServer && localServer->netServer->is_disconnected();
|
||||
}
|
||||
|
||||
bool ConnectionManager::host_exists() {
|
||||
return localServer != nullptr;
|
||||
}
|
||||
|
||||
bool ConnectionManager::client_exists() {
|
||||
return client != nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue