Changeset View
Changeset View
Standalone View
Standalone View
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)) | |||||
Stan: Why not CStr8? | |||||
Done Inline ActionsUnless necessary, it's standard conventions to just use CStr wraitii: Unless necessary, it's standard conventions to just use CStr | |||||
{ | { | ||||
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. | |||||
Not Done Inline ActionsIn theory yes, but what if server fails to get its local ip? What happens then? Silier: In theory yes, but what if server fails to get its local ip? What happens then? | |||||
Done Inline ActionsIt'll either fail in the next call to this function (that won't use STUN so won't take this branch), in e.g. SetupConnection, or fail when the reply fails to arrive. So for the user, this is transparent. Note that the return value is irrelevant anyways, since it isn't checked atm. wraitii: It'll either fail in the next call to this function (that won't use STUN so won't take this… | |||||
Not Done Inline Actionsyou should edit comment in h file Silier: you should edit comment in h file | |||||
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
Why not CStr8?