Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/network/NetClient.cpp
Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | if (!enetClient) | ||||
PushGuiMessage( | PushGuiMessage( | ||||
"type", "netstatus", | "type", "netstatus", | ||||
"status", "disconnected", | "status", "disconnected", | ||||
"reason", static_cast<i32>(NDR_STUN_PORT_FAILED)); | "reason", static_cast<i32>(NDR_STUN_PORT_FAILED)); | ||||
return false; | return false; | ||||
} | } | ||||
StunClient::StunEndpoint stunEndpoint; | StunClient::StunEndpoint stunEndpoint; | ||||
if (!StunClient::FindStunEndpointJoin(*enetClient, stunEndpoint)) | CStr ip; | ||||
if (!StunClient::FindStunEndpointJoin(*enetClient, stunEndpoint, ip)) | |||||
{ | { | ||||
PushGuiMessage( | PushGuiMessage( | ||||
"type", "netstatus", | "type", "netstatus", | ||||
"status", "disconnected", | "status", "disconnected", | ||||
"reason", static_cast<i32>(NDR_STUN_ENDPOINT_FAILED)); | "reason", static_cast<i32>(NDR_STUN_ENDPOINT_FAILED)); | ||||
return false; | return false; | ||||
} | } | ||||
// If the host is on the same network, we risk failing to connect | |||||
// on routers that don't support NAT hairpinning/NAT loopback. | |||||
// To work around that, send again a connection data request, but for internal IP this time. | |||||
if (ip == m_ServerAddress) | |||||
{ | |||||
g_XmppClient->SendIqGetConnectionData(m_HostJID, m_Password, true); | |||||
// Return true anyways - we're on a success path here. | |||||
return true; | |||||
} | |||||
g_XmppClient->SendStunEndpointToHost(stunEndpoint, hostJID); | g_XmppClient->SendStunEndpointToHost(stunEndpoint, hostJID); | ||||
SDL_Delay(1000); | SDL_Delay(1000); | ||||
StunClient::SendHolePunchingMessages(*enetClient, m_ServerAddress, m_ServerPort); | StunClient::SendHolePunchingMessages(*enetClient, m_ServerAddress, m_ServerPort); | ||||
} | } | ||||
if (!g_NetClient->SetupConnection(enetClient)) | if (!g_NetClient->SetupConnection(enetClient)) | ||||
▲ Show 20 Lines • Show All 692 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator