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 "online/request_manager.hpp"
#include "utils/log.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; m_peer_id = peer_id;
} } // GetPeerAddress
// ----------------------------------------------------------------------------
GetPeerAddress::~GetPeerAddress() GetPeerAddress::~GetPeerAddress()
{ {
} } // ~GetPeerAddress
// ----------------------------------------------------------------------------
void GetPeerAddress::setup() void GetPeerAddress::setup()
{ {
m_state = NONE; m_state = NONE;
m_request = NULL; m_request = NULL;
} } // setup
// ----------------------------------------------------------------------------
void GetPeerAddress::asynchronousUpdate() void GetPeerAddress::asynchronousUpdate()
{ {
if (m_state == NONE) if (m_state == NONE)
{ {
m_request = new Online::XMLRequest(); 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); m_request->addParameter("peer_id", m_peer_id);
Online::RequestManager::get()->addRequest(m_request); Online::RequestManager::get()->addRequest(m_request);
@ -93,9 +98,10 @@ void GetPeerAddress::asynchronousUpdate()
m_request = NULL; m_request = NULL;
requestTerminate(); requestTerminate();
} }
} } // asynchronousUpdate
// ----------------------------------------------------------------------------
void GetPeerAddress::setPeerID(uint32_t peer_id) void GetPeerAddress::setPeerID(uint32_t peer_id)
{ {
m_peer_id = peer_id; m_peer_id = peer_id;
} } // setPeerID

View File

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

View File

@ -190,10 +190,6 @@ std::string GetPublicAddress::parseStunResponse()
return "STUN response is invalid."; return "STUN response is invalid.";
} // while true } // while true
// The address and the port are known, so the connection can be closed
m_state = EXITING;
requestTerminate();
return ""; return "";
} // parseStunResponse } // parseStunResponse
@ -212,7 +208,13 @@ void GetPublicAddress::asynchronousUpdate()
if (message != "") if (message != "")
{ {
Log::warn("GetPublicAddress", "%s", message.c_str()); 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. /** This is the central game setup protocol running in the server.
* It starts with detecting the public ip address and port of this * It starts with detecting the public ip address and port of this
* host (GetPublicIpAddress). * host (GetPublicAddress).
*/ */
ServerLobbyRoomProtocol::ServerLobbyRoomProtocol() : LobbyRoomProtocol(NULL) ServerLobbyRoomProtocol::ServerLobbyRoomProtocol() : LobbyRoomProtocol(NULL)
{ {