Cosmetic changes only.

This commit is contained in:
hiker 2015-10-28 08:57:05 +11:00
parent e919b97037
commit 5df6c225ef
4 changed files with 48 additions and 35 deletions

View File

@ -25,27 +25,32 @@
#include "online/request_manager.hpp"
#include "utils/log.hpp"
GetPeerAddress::GetPeerAddress(uint32_t peer_id, CallbackObject* callback_object) : Protocol(callback_object, PROTOCOL_SILENT)
GetPeerAddress::GetPeerAddress(uint32_t peer_id, CallbackObject* callback_object)
: Protocol(callback_object, PROTOCOL_SILENT)
{
m_peer_id = peer_id;
}
} // GetPeerAddress
// ----------------------------------------------------------------------------
GetPeerAddress::~GetPeerAddress()
{
}
} // ~GetPeerAddress
// ----------------------------------------------------------------------------
void GetPeerAddress::setup()
{
m_state = NONE;
m_request = NULL;
}
} // setup
// ----------------------------------------------------------------------------
void GetPeerAddress::asynchronousUpdate()
{
if (m_state == NONE)
{
m_request = new Online::XMLRequest();
PlayerManager::setUserDetails(m_request, "get", Online::API::SERVER_PATH);
PlayerManager::setUserDetails(m_request, "get",
Online::API::SERVER_PATH);
m_request->addParameter("peer_id", m_peer_id);
Online::RequestManager::get()->addRequest(m_request);
@ -93,9 +98,10 @@ void GetPeerAddress::asynchronousUpdate()
m_request = NULL;
requestTerminate();
}
}
} // asynchronousUpdate
// ----------------------------------------------------------------------------
void GetPeerAddress::setPeerID(uint32_t peer_id)
{
m_peer_id = peer_id;
}
} // setPeerID

View File

@ -25,29 +25,34 @@ namespace Online { class XMLRequest; }
class GetPeerAddress : public Protocol
{
public:
GetPeerAddress(uint32_t peer_id, CallbackObject* callback_object);
virtual ~GetPeerAddress();
private:
uint32_t m_peer_id;
Online::XMLRequest* m_request;
virtual bool notifyEvent(Event* event) { return true; }
virtual bool notifyEventAsynchronous(Event* event) { return true; }
virtual void setup();
virtual void update() {}
virtual void asynchronousUpdate();
enum STATE
{
NONE,
REQUEST_PENDING,
DONE,
EXITING
};
STATE m_state;
void setPeerID(uint32_t m_peer_id);
protected:
uint32_t m_peer_id;
Online::XMLRequest* m_request;
enum STATE
{
NONE,
REQUEST_PENDING,
DONE,
EXITING
};
STATE m_state;
public:
GetPeerAddress(uint32_t peer_id, CallbackObject* callback_object);
virtual ~GetPeerAddress();
};
virtual void setup();
virtual void asynchronousUpdate();
void setPeerID(uint32_t m_peer_id);
// ------------------------------------------------------------------------
virtual void update() {}
// ------------------------------------------------------------------------
virtual bool notifyEvent(Event* event) { return true; }
// ------------------------------------------------------------------------
virtual bool notifyEventAsynchronous(Event* event) { return true; }
}; // class GetPeerAddress
#endif // GET_PEER_ADDRESS_HPP

View File

@ -190,10 +190,6 @@ std::string GetPublicAddress::parseStunResponse()
return "STUN response is invalid.";
} // while true
// The address and the port are known, so the connection can be closed
m_state = EXITING;
requestTerminate();
return "";
} // parseStunResponse
@ -212,7 +208,13 @@ void GetPublicAddress::asynchronousUpdate()
if (message != "")
{
Log::warn("GetPublicAddress", "%s", message.c_str());
m_state = NOTHING_DONE;
m_state = NOTHING_DONE; // try again
}
else
{
// The address and the port are known, so the connection can be closed
m_state = EXITING;
requestTerminate();
}
}
} // asynchronousUpdate
} // asynchronousUpdate

View File

@ -39,7 +39,7 @@
/** This is the central game setup protocol running in the server.
* It starts with detecting the public ip address and port of this
* host (GetPublicIpAddress).
* host (GetPublicAddress).
*/
ServerLobbyRoomProtocol::ServerLobbyRoomProtocol() : LobbyRoomProtocol(NULL)
{