#1 - ClientWorldController refactoring

This commit is contained in:
Martin Slachta
2026-08-03 23:30:18 +02:00
parent f4174eb0c7
commit a097f4d4b0
35 changed files with 899 additions and 1010 deletions
@@ -11,7 +11,6 @@ ServerConnection::ServerConnection(Address address) :
}
tl::expected<void, msg::MessageError> ServerConnection::start() {
// Create the endpoint
auto endpoint_r = msg::MessageEndpoint::create();
if(!endpoint_r) {
m_status = ConnectionStatus::Failed;
@@ -21,7 +20,6 @@ tl::expected<void, msg::MessageError> ServerConnection::start() {
m_endpoint = std::move(endpoint_r.value());
// Connect to the server
auto server_r = m_endpoint->connect(m_address.ip_string(), m_address.port());
if(!server_r) {
m_status = ConnectionStatus::Failed;
@@ -44,13 +42,11 @@ void ServerConnection::update() {
m_endpoint->update();
// Check if the connection has become established
if(m_status == ConnectionStatus::Connecting && m_server) {
if(m_server->is_established()) {
m_status = ConnectionStatus::Connected;
spdlog::info("Connected to server at {}", m_address.to_string());
} else {
// Check for timeout
auto elapsed = Clock::now() - m_started_at;
if(elapsed >= CONNECT_TIMEOUT) {
m_status = ConnectionStatus::Failed;
@@ -61,24 +57,5 @@ void ServerConnection::update() {
}
}
ConnectionStatus ServerConnection::status() const {
return m_status;
}
const std::string& ServerConnection::error() const {
return m_error;
}
const Address& ServerConnection::address() const {
return m_address;
}
msg::MessageEndpoint* ServerConnection::endpoint() const {
return m_endpoint.get();
}
msg::MessageConnection* ServerConnection::server() const {
return m_server;
}
}