#include "includes.h" XServer::LoginServer *XServer::LoginServer::instance = nullptr; void XServer::LoginServer::Start() { if (instance != nullptr) { cout << "WARNING: Instance of LoginServer already exists!" << endl; Shutdown(); } cout << "INFO: Starting up LoginServer" << endl; instance = new LoginServer(); } XServer::LoginServer::LoginServer() { } /* done = false; listener.SetBlocking(false); if (listener.Listen(LS_PORT) == sf::Socket::Error) { cerr << "ERROR: LoginServer failed to listen on port " << LS_PORT << endl; throw(273); } thread = new sf::Thread([&](){this->Loop();}); thread->Launch(); cout << "INFO: LoginServer up and listening on port " << LS_PORT << endl; } void XServer::LoginServer::Loop() { while (!done) { static sf::TcpSocket* next(new sf::TcpSocket()); if (listener.Accept(*next) == sf::Socket::Done) { cout << "INFO: Player connected from " << next->GetRemoteAddress() << ":" << next->GetRemotePort() << endl; //Do stuff with next next = new sf::TcpSocket(); } sf::Sleep(0.1); } } void Server::LoginServer::Shutdown() { cout << "INFO: Shutting down LoginServer" << endl; instance->done = true; instance->thread->Wait(); delete instance; instance = nullptr; }*/