Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/lobby/XmppClient.cpp
Show All 14 Lines | |||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "XmppClient.h" | #include "XmppClient.h" | ||||
#include "StanzaExtensions.h" | #include "StanzaExtensions.h" | ||||
#ifdef WIN32 | |||||
# include <winsock2.h> | |||||
#endif | |||||
#include "i18n/L10n.h" | #include "i18n/L10n.h" | ||||
#include "lib/external_libraries/enet.h" | |||||
#include "lib/utf8.h" | #include "lib/utf8.h" | ||||
#include "network/NetServer.h" | #include "network/NetServer.h" | ||||
#include "network/NetClient.h" | #include "network/NetClient.h" | ||||
#include "network/StunClient.h" | #include "network/StunClient.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/GUID.h" | #include "ps/GUID.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
▲ Show 20 Lines • Show All 841 Lines • ▼ Show 20 Lines | if (gq) | ||||
return true; | return true; | ||||
} | } | ||||
std::string publicIP = gq->m_GameList.front()->findAttribute("ip").to_string(); | std::string publicIP = gq->m_GameList.front()->findAttribute("ip").to_string(); | ||||
if (publicIP.empty()) | if (publicIP.empty()) | ||||
{ | { | ||||
LOGWARNING("XmppClient: Received game with no IP in response to Game Register"); | LOGWARNING("XmppClient: Received game with no IP in response to Game Register"); | ||||
return true; | return true; | ||||
} | } | ||||
g_NetServer->SetConnectionData(publicIP, g_NetServer->GetPublicPort(), false); | g_NetServer->SetConnectionData(publicIP, g_NetServer->GetPublicPort()); | ||||
return true; | return true; | ||||
} | } | ||||
for (const glooxwrapper::Tag* const& t : m_GameList) | for (const glooxwrapper::Tag* const& t : m_GameList) | ||||
glooxwrapper::Tag::free(t); | glooxwrapper::Tag::free(t); | ||||
m_GameList.clear(); | m_GameList.clear(); | ||||
for (const glooxwrapper::Tag* const& t : gq->m_GameList) | for (const glooxwrapper::Tag* const& t : gq->m_GameList) | ||||
▲ Show 20 Lines • Show All 584 Lines • ▼ Show 20 Lines | #define DEBUG_CASE(X, Y) case gloox::X: return g_L10n.Translate("Error") + " (" + Y + ")" | ||||
DEBUG_CASE(RegistrationNotAllowed, "Server does not permit password changes"); | DEBUG_CASE(RegistrationNotAllowed, "Server does not permit password changes"); | ||||
default: | default: | ||||
return ""; | return ""; | ||||
} | } | ||||
#undef DEBUG_CASE | #undef DEBUG_CASE | ||||
#undef CASE | #undef CASE | ||||
} | } | ||||
void XmppClient::SendStunEndpointToHost(const StunClient::StunEndpoint& stunEndpoint, const std::string& hostJIDStr) | void XmppClient::SendStunEndpointToHost(const std::string& ip, u16 port, const std::string& hostJIDStr) | ||||
{ | { | ||||
DbgXMPP("SendStunEndpointToHost " << hostJIDStr); | DbgXMPP("SendStunEndpointToHost " << hostJIDStr); | ||||
char ipStr[256] = "(error)"; | |||||
ENetAddress addr; | |||||
addr.host = ntohl(stunEndpoint.ip); | |||||
enet_address_get_host_ip(&addr, ipStr, ARRAY_SIZE(ipStr)); | |||||
glooxwrapper::JID hostJID(hostJIDStr); | glooxwrapper::JID hostJID(hostJIDStr); | ||||
glooxwrapper::Jingle::Session session = m_sessionManager->createSession(hostJID); | glooxwrapper::Jingle::Session session = m_sessionManager->createSession(hostJID); | ||||
session.sessionInitiate(ipStr, stunEndpoint.port); | session.sessionInitiate(ip.c_str(), port); | ||||
} | } | ||||
void XmppClient::handleSessionAction(gloox::Jingle::Action action, glooxwrapper::Jingle::Session& session, const glooxwrapper::Jingle::Session::Jingle& jingle) | void XmppClient::handleSessionAction(gloox::Jingle::Action action, glooxwrapper::Jingle::Session& session, const glooxwrapper::Jingle::Session::Jingle& jingle) | ||||
{ | { | ||||
if (action == gloox::Jingle::SessionInitiate) | if (action == gloox::Jingle::SessionInitiate) | ||||
handleSessionInitiation(session, jingle); | handleSessionInitiation(session, jingle); | ||||
} | } | ||||
Show All 18 Lines |
Wildfire Games · Phabricator