CLOUD: Make "Run server" button active

It should show the real server's IP over there, but that doesn't work
yet.
This commit is contained in:
Alexander Tkachev 2016-07-05 16:31:52 +06:00
parent 3da38ca60b
commit e601c39802
6 changed files with 56 additions and 9 deletions

View file

@ -71,7 +71,10 @@ void LocalWebserver::stopTimer() {
void LocalWebserver::start() {
_handleMutex.lock();
_stopOnIdle = false;
if (_timerStarted) return;
if (_timerStarted) {
_handleMutex.unlock();
return;
}
startTimer();
// Create a listening TCP socket
@ -79,6 +82,11 @@ void LocalWebserver::start() {
if (SDLNet_ResolveHost(&ip, NULL, SERVER_PORT) == -1) {
error("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
}
_address = Common::String::format(
"http://%u.%u.%u.%u:%u/",
(ip.host>>24)&0xFF, (ip.host >> 16) & 0xFF, (ip.host >> 8) & 0xFF, ip.host & 0xFF,
SERVER_PORT
);
_serverSocket = SDLNet_TCP_Open(&ip);
if (!_serverSocket) {
error("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
@ -130,8 +138,18 @@ void LocalWebserver::removePathHandler(Common::String path) {
_pathHandlers.erase(path);
}
Common::String LocalWebserver::getAddress() { return _address; }
IndexPageHandler &LocalWebserver::indexPageHandler() { return _indexPageHandler; }
bool LocalWebserver::isRunning() {
bool result = false;
_handleMutex.lock();
result = _timerStarted;
_handleMutex.unlock();
return result;
}
void LocalWebserver::handle() {
_handleMutex.lock();
int numready = SDLNet_CheckSockets(_set, 0);