Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/XmppClient.cpp
Show First 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | void XmppClient::SendIqGetProfile(const std::string& player) | ||||
iq.addExtension(b); | iq.addExtension(b); | ||||
DbgXMPP("SendIqGetProfile [" << tag_xml(iq) << "]"); | DbgXMPP("SendIqGetProfile [" << tag_xml(iq) << "]"); | ||||
m_client->send(iq); | m_client->send(iq); | ||||
} | } | ||||
/** | /** | ||||
* Request the Connection data (ip, port...) from the server. | * Request the Connection data (ip, port...) from the server. | ||||
*/ | */ | ||||
void XmppClient::SendIqGetConnectionData(const std::string& jid, const std::string& password) | void XmppClient::SendIqGetConnectionData(const std::string& jid, const std::string& password, bool localIP) | ||||
{ | { | ||||
glooxwrapper::JID targetJID(jid); | glooxwrapper::JID targetJID(jid); | ||||
ConnectionData* connectionData = new ConnectionData(); | ConnectionData* connectionData = new ConnectionData(); | ||||
connectionData->m_Password = password; | connectionData->m_Password = password; | ||||
connectionData->m_UseSTUN = localIP ? "0" : "1"; | |||||
Silier: hmm, looks missleading | |||||
glooxwrapper::IQ iq(gloox::IQ::Get, targetJID, m_client->getID()); | glooxwrapper::IQ iq(gloox::IQ::Get, targetJID, m_client->getID()); | ||||
iq.addExtension(connectionData); | iq.addExtension(connectionData); | ||||
m_connectionDataJid = iq.from().full(); | m_connectionDataJid = iq.from().full(); | ||||
m_connectionDataIqId = iq.id().to_string(); | m_connectionDataIqId = iq.id().to_string(); | ||||
DbgXMPP("SendIqGetConnectionData [" << tag_xml(iq) << "]"); | DbgXMPP("SendIqGetConnectionData [" << tag_xml(iq) << "]"); | ||||
m_client->send(iq); | m_client->send(iq); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 608 Lines • ▼ Show 20 Lines | if (cd) | ||||
response.addExtension(connectionData); | response.addExtension(connectionData); | ||||
m_client->send(response); | m_client->send(response); | ||||
return true; | return true; | ||||
} | } | ||||
glooxwrapper::IQ response(gloox::IQ::Result, iq.from(), iq.id()); | glooxwrapper::IQ response(gloox::IQ::Result, iq.from(), iq.id()); | ||||
ConnectionData* connectionData = new ConnectionData(); | ConnectionData* connectionData = new ConnectionData(); | ||||
connectionData->m_Ip = g_NetServer->GetPublicIp();; | if (cd->m_UseSTUN == "1") | ||||
SilierUnsubmitted Not Done Inline Actionsalso this if does not look correct just by reading the code to me Silier: also this if does not look correct just by reading the code to me
maybe it would be cleaner to… | |||||
{ | |||||
connectionData->m_Ip = g_NetServer->GetPublicIp(); | |||||
connectionData->m_Port = std::to_string(g_NetServer->GetPublicPort()); | connectionData->m_Port = std::to_string(g_NetServer->GetPublicPort()); | ||||
connectionData->m_UseSTUN = g_NetServer->GetUseSTUN() ? "true" : ""; | connectionData->m_UseSTUN = g_NetServer->GetUseSTUN() ? "true" : ""; | ||||
} | |||||
else | |||||
{ | |||||
CStr ip; | |||||
if (StunClient::FindLocalIP(ip)) | |||||
{ | |||||
connectionData->m_Ip = ip; | |||||
connectionData->m_Port = std::to_string(g_NetServer->GetPublicPort()); | |||||
connectionData->m_UseSTUN = ""; | |||||
} | |||||
else | |||||
connectionData->m_Error = "local_ip_failed"; | |||||
} | |||||
Not Done Inline ActionsIt could return more helpful code Silier: It could return more helpful code | |||||
response.addExtension(connectionData); | response.addExtension(connectionData); | ||||
m_client->send(response); | m_client->send(response); | ||||
} | } | ||||
} | } | ||||
else if (iq.subtype() == gloox::IQ::Error) | else if (iq.subtype() == gloox::IQ::Error) | ||||
CreateGUIMessage("system", "error", std::time(nullptr), "text", iq.error_error()); | CreateGUIMessage("system", "error", std::time(nullptr), "text", iq.error_error()); | ||||
▲ Show 20 Lines • Show All 501 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
hmm, looks missleading