Merge pull request #9455 from lioncash/traversal

TraversalProto: Minor cleanup
This commit is contained in:
Léo Lam 2021-01-27 15:51:29 +01:00 committed by GitHub
commit 4ba9bb26e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 97 additions and 87 deletions

View File

@ -48,32 +48,32 @@ void TraversalClient::ReconnectToServer()
} }
m_ServerAddress.port = m_port; m_ServerAddress.port = m_port;
m_State = Connecting; m_State = State::Connecting;
TraversalPacket hello = {}; TraversalPacket hello = {};
hello.type = TraversalPacketHelloFromClient; hello.type = TraversalPacketType::HelloFromClient;
hello.helloFromClient.protoVersion = TraversalProtoVersion; hello.helloFromClient.protoVersion = TraversalProtoVersion;
SendTraversalPacket(hello); SendTraversalPacket(hello);
if (m_Client) if (m_Client)
m_Client->OnTraversalStateChanged(); m_Client->OnTraversalStateChanged();
} }
static ENetAddress MakeENetAddress(TraversalInetAddress* address) static ENetAddress MakeENetAddress(const TraversalInetAddress& address)
{ {
ENetAddress eaddr; ENetAddress eaddr{};
if (address->isIPV6) if (address.isIPV6)
{ {
eaddr.port = 0; // no support yet :( eaddr.port = 0; // no support yet :(
} }
else else
{ {
eaddr.host = address->address[0]; eaddr.host = address.address[0];
eaddr.port = ntohs(address->port); eaddr.port = ntohs(address.port);
} }
return eaddr; return eaddr;
} }
void TraversalClient::ConnectToClient(const std::string& host) void TraversalClient::ConnectToClient(std::string_view host)
{ {
if (host.size() > sizeof(TraversalHostId)) if (host.size() > sizeof(TraversalHostId))
{ {
@ -81,8 +81,8 @@ void TraversalClient::ConnectToClient(const std::string& host)
return; return;
} }
TraversalPacket packet = {}; TraversalPacket packet = {};
packet.type = TraversalPacketConnectPlease; packet.type = TraversalPacketType::ConnectPlease;
memcpy(packet.connectPlease.hostId.data(), host.c_str(), host.size()); memcpy(packet.connectPlease.hostId.data(), host.data(), host.size());
m_ConnectRequestId = SendTraversalPacket(packet); m_ConnectRequestId = SendTraversalPacket(packet);
m_PendingConnect = true; m_PendingConnect = true;
} }
@ -129,7 +129,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
u8 ok = 1; u8 ok = 1;
switch (packet->type) switch (packet->type)
{ {
case TraversalPacketAck: case TraversalPacketType::Ack:
if (!packet->ack.ok) if (!packet->ack.ok)
{ {
OnFailure(FailureReason::ServerForgotAboutUs); OnFailure(FailureReason::ServerForgotAboutUs);
@ -144,8 +144,8 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
} }
} }
break; break;
case TraversalPacketHelloFromServer: case TraversalPacketType::HelloFromServer:
if (m_State != Connecting) if (!IsConnecting())
break; break;
if (!packet->helloFromServer.ok) if (!packet->helloFromServer.ok)
{ {
@ -153,14 +153,14 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
break; break;
} }
m_HostId = packet->helloFromServer.yourHostId; m_HostId = packet->helloFromServer.yourHostId;
m_State = Connected; m_State = State::Connected;
if (m_Client) if (m_Client)
m_Client->OnTraversalStateChanged(); m_Client->OnTraversalStateChanged();
break; break;
case TraversalPacketPleaseSendPacket: case TraversalPacketType::PleaseSendPacket:
{ {
// security is overrated. // security is overrated.
ENetAddress addr = MakeENetAddress(&packet->pleaseSendPacket.address); ENetAddress addr = MakeENetAddress(packet->pleaseSendPacket.address);
if (addr.port != 0) if (addr.port != 0)
{ {
char message[] = "Hello from Dolphin Netplay..."; char message[] = "Hello from Dolphin Netplay...";
@ -176,8 +176,8 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
} }
break; break;
} }
case TraversalPacketConnectReady: case TraversalPacketType::ConnectReady:
case TraversalPacketConnectFailed: case TraversalPacketType::ConnectFailed:
{ {
if (!m_PendingConnect || packet->connectReady.requestId != m_ConnectRequestId) if (!m_PendingConnect || packet->connectReady.requestId != m_ConnectRequestId)
break; break;
@ -187,8 +187,8 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
if (!m_Client) if (!m_Client)
break; break;
if (packet->type == TraversalPacketConnectReady) if (packet->type == TraversalPacketType::ConnectReady)
m_Client->OnConnectReady(MakeENetAddress(&packet->connectReady.address)); m_Client->OnConnectReady(MakeENetAddress(packet->connectReady.address));
else else
m_Client->OnConnectFailed(packet->connectFailed.reason); m_Client->OnConnectFailed(packet->connectFailed.reason);
break; break;
@ -197,10 +197,10 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", packet->type); WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", packet->type);
break; break;
} }
if (packet->type != TraversalPacketAck) if (packet->type != TraversalPacketType::Ack)
{ {
TraversalPacket ack = {}; TraversalPacket ack = {};
ack.type = TraversalPacketAck; ack.type = TraversalPacketType::Ack;
ack.requestId = packet->requestId; ack.requestId = packet->requestId;
ack.ack.ok = ok; ack.ack.ok = ok;
@ -214,7 +214,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
void TraversalClient::OnFailure(FailureReason reason) void TraversalClient::OnFailure(FailureReason reason)
{ {
m_State = Failure; m_State = State::Failure;
m_FailureReason = reason; m_FailureReason = reason;
if (m_Client) if (m_Client)
@ -257,10 +257,10 @@ void TraversalClient::HandleResends()
void TraversalClient::HandlePing() void TraversalClient::HandlePing()
{ {
const u32 now = enet_time_get(); const u32 now = enet_time_get();
if (m_State == Connected && now - m_PingTime >= 500) if (IsConnected() && now - m_PingTime >= 500)
{ {
TraversalPacket ping = {}; TraversalPacket ping = {};
ping.type = TraversalPacketPing; ping.type = TraversalPacketType::Ping;
ping.ping.hostId = m_HostId; ping.ping.hostId = m_HostId;
SendTraversalPacket(ping); SendTraversalPacket(ping);
m_PingTime = now; m_PingTime = now;

View File

@ -6,6 +6,7 @@
#include <list> #include <list>
#include <memory> #include <memory>
#include <string> #include <string>
#include <string_view>
#include <enet/enet.h> #include <enet/enet.h>
@ -19,17 +20,17 @@ public:
virtual ~TraversalClientClient() = default; virtual ~TraversalClientClient() = default;
virtual void OnTraversalStateChanged() = 0; virtual void OnTraversalStateChanged() = 0;
virtual void OnConnectReady(ENetAddress addr) = 0; virtual void OnConnectReady(ENetAddress addr) = 0;
virtual void OnConnectFailed(u8 reason) = 0; virtual void OnConnectFailed(TraversalConnectFailedReason reason) = 0;
}; };
class TraversalClient class TraversalClient
{ {
public: public:
enum State enum class State
{ {
Connecting, Connecting,
Connected, Connected,
Failure Failure,
}; };
enum class FailureReason enum class FailureReason
{ {
@ -46,8 +47,12 @@ public:
State GetState() const; State GetState() const;
FailureReason GetFailureReason() const; FailureReason GetFailureReason() const;
bool HasFailed() const { return m_State == State::Failure; }
bool IsConnecting() const { return m_State == State::Connecting; }
bool IsConnected() const { return m_State == State::Connected; }
void Reset(); void Reset();
void ConnectToClient(const std::string& host); void ConnectToClient(std::string_view host);
void ReconnectToServer(); void ReconnectToServer();
void Update(); void Update();
void HandleResends(); void HandleResends();

View File

@ -1,44 +1,43 @@
// This file is public domain, in case it's useful to anyone. -comex // This file is public domain, in case it's useful to anyone. -comex
#pragma once #pragma once
#include <array> #include <array>
#include <cstddef>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#define NETPLAY_CODE_SIZE 8 constexpr size_t NETPLAY_CODE_SIZE = 8;
typedef std::array<char, NETPLAY_CODE_SIZE> TraversalHostId; using TraversalHostId = std::array<char, NETPLAY_CODE_SIZE>;
typedef u64 TraversalRequestId; using TraversalRequestId = u64;
enum TraversalPacketType enum class TraversalPacketType : u8
{ {
// [*->*] // [*->*]
TraversalPacketAck = 0, Ack = 0,
// [c->s] // [c->s]
TraversalPacketPing = 1, Ping = 1,
// [c->s] // [c->s]
TraversalPacketHelloFromClient = 2, HelloFromClient = 2,
// [s->c] // [s->c]
TraversalPacketHelloFromServer = 3, HelloFromServer = 3,
// [c->s] When connecting, first the client asks the central server... // [c->s] When connecting, first the client asks the central server...
TraversalPacketConnectPlease = 4, ConnectPlease = 4,
// [s->c] ...who asks the game host to send a UDP packet to the // [s->c] ...who asks the game host to send a UDP packet to the
// client... (an ack implies success) // client... (an ack implies success)
TraversalPacketPleaseSendPacket = 5, PleaseSendPacket = 5,
// [s->c] ...which the central server relays back to the client. // [s->c] ...which the central server relays back to the client.
TraversalPacketConnectReady = 6, ConnectReady = 6,
// [s->c] Alternately, the server might not have heard of this host. // [s->c] Alternately, the server might not have heard of this host.
TraversalPacketConnectFailed = 7 ConnectFailed = 7,
}; };
enum constexpr u8 TraversalProtoVersion = 0;
{
TraversalProtoVersion = 0
};
enum TraversalConnectFailedReason enum class TraversalConnectFailedReason : u8
{ {
TraversalConnectFailedClientDidntRespond = 0, ClientDidntRespond = 0,
TraversalConnectFailedClientFailure, ClientFailure,
TraversalConnectFailedNoSuchClient NoSuchClient,
}; };
#pragma pack(push, 1) #pragma pack(push, 1)
@ -50,7 +49,7 @@ struct TraversalInetAddress
}; };
struct TraversalPacket struct TraversalPacket
{ {
u8 type; TraversalPacketType type;
TraversalRequestId requestId; TraversalRequestId requestId;
union union
{ {
@ -88,7 +87,7 @@ struct TraversalPacket
struct struct
{ {
TraversalRequestId requestId; TraversalRequestId requestId;
u8 reason; TraversalConnectFailedReason reason;
} connectFailed; } connectFailed;
}; };
}; };

View File

@ -185,8 +185,9 @@ static const char* SenderName(sockaddr_in6* addr)
static void TrySend(const void* buffer, size_t size, sockaddr_in6* addr) static void TrySend(const void* buffer, size_t size, sockaddr_in6* addr)
{ {
#if DEBUG #if DEBUG
printf("-> %d %llu %s\n", ((TraversalPacket*)buffer)->type, const auto* packet = static_cast<const TraversalPacket*>(buffer);
(long long)((TraversalPacket*)buffer)->requestId, SenderName(addr)); printf("-> %d %llu %s\n", static_cast<int>(packet->type),
static_cast<long long>(packet->requestId), SenderName(addr));
#endif #endif
if ((size_t)sendto(sock, buffer, size, 0, (sockaddr*)addr, sizeof(*addr)) != size) if ((size_t)sendto(sock, buffer, size, 0, (sockaddr*)addr, sizeof(*addr)) != size)
{ {
@ -227,7 +228,7 @@ static void ResendPackets()
{ {
if (info->tries >= NUMBER_OF_TRIES) if (info->tries >= NUMBER_OF_TRIES)
{ {
if (info->packet.type == TraversalPacketPleaseSendPacket) if (info->packet.type == TraversalPacketType::PleaseSendPacket)
{ {
todoFailures.push_back(std::make_pair(info->packet.pleaseSendPacket.address, info->misc)); todoFailures.push_back(std::make_pair(info->packet.pleaseSendPacket.address, info->misc));
} }
@ -245,21 +246,22 @@ static void ResendPackets()
for (const auto& p : todoFailures) for (const auto& p : todoFailures)
{ {
TraversalPacket* fail = AllocPacket(MakeSinAddr(p.first)); TraversalPacket* fail = AllocPacket(MakeSinAddr(p.first));
fail->type = TraversalPacketConnectFailed; fail->type = TraversalPacketType::ConnectFailed;
fail->connectFailed.requestId = p.second; fail->connectFailed.requestId = p.second;
fail->connectFailed.reason = TraversalConnectFailedClientDidntRespond; fail->connectFailed.reason = TraversalConnectFailedReason::ClientDidntRespond;
} }
} }
static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr) static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
{ {
#if DEBUG #if DEBUG
printf("<- %d %llu %s\n", packet->type, (long long)packet->requestId, SenderName(addr)); printf("<- %d %llu %s\n", static_cast<int>(packet->type),
static_cast<long long>(packet->requestId), SenderName(addr));
#endif #endif
bool packetOk = true; bool packetOk = true;
switch (packet->type) switch (packet->type)
{ {
case TraversalPacketAck: case TraversalPacketType::Ack:
{ {
auto it = outgoingPackets.find(packet->requestId); auto it = outgoingPackets.find(packet->requestId);
if (it == outgoingPackets.end()) if (it == outgoingPackets.end())
@ -267,37 +269,37 @@ static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
OutgoingPacketInfo* info = &it->second; OutgoingPacketInfo* info = &it->second;
if (info->packet.type == TraversalPacketPleaseSendPacket) if (info->packet.type == TraversalPacketType::PleaseSendPacket)
{ {
TraversalPacket* ready = AllocPacket(MakeSinAddr(info->packet.pleaseSendPacket.address)); TraversalPacket* ready = AllocPacket(MakeSinAddr(info->packet.pleaseSendPacket.address));
if (packet->ack.ok) if (packet->ack.ok)
{ {
ready->type = TraversalPacketConnectReady; ready->type = TraversalPacketType::ConnectReady;
ready->connectReady.requestId = info->misc; ready->connectReady.requestId = info->misc;
ready->connectReady.address = MakeInetAddress(info->dest); ready->connectReady.address = MakeInetAddress(info->dest);
} }
else else
{ {
ready->type = TraversalPacketConnectFailed; ready->type = TraversalPacketType::ConnectFailed;
ready->connectFailed.requestId = info->misc; ready->connectFailed.requestId = info->misc;
ready->connectFailed.reason = TraversalConnectFailedClientFailure; ready->connectFailed.reason = TraversalConnectFailedReason::ClientFailure;
} }
} }
outgoingPackets.erase(it); outgoingPackets.erase(it);
break; break;
} }
case TraversalPacketPing: case TraversalPacketType::Ping:
{ {
auto r = EvictFind(connectedClients, packet->ping.hostId, true); auto r = EvictFind(connectedClients, packet->ping.hostId, true);
packetOk = r.found; packetOk = r.found;
break; break;
} }
case TraversalPacketHelloFromClient: case TraversalPacketType::HelloFromClient:
{ {
u8 ok = packet->helloFromClient.protoVersion <= TraversalProtoVersion; u8 ok = packet->helloFromClient.protoVersion <= TraversalProtoVersion;
TraversalPacket* reply = AllocPacket(*addr); TraversalPacket* reply = AllocPacket(*addr);
reply->type = TraversalPacketHelloFromServer; reply->type = TraversalPacketType::HelloFromServer;
reply->helloFromServer.ok = ok; reply->helloFromServer.ok = ok;
if (ok) if (ok)
{ {
@ -323,32 +325,34 @@ static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
} }
break; break;
} }
case TraversalPacketConnectPlease: case TraversalPacketType::ConnectPlease:
{ {
TraversalHostId& hostId = packet->connectPlease.hostId; TraversalHostId& hostId = packet->connectPlease.hostId;
auto r = EvictFind(connectedClients, hostId); auto r = EvictFind(connectedClients, hostId);
if (!r.found) if (!r.found)
{ {
TraversalPacket* reply = AllocPacket(*addr); TraversalPacket* reply = AllocPacket(*addr);
reply->type = TraversalPacketConnectFailed; reply->type = TraversalPacketType::ConnectFailed;
reply->connectFailed.requestId = packet->requestId; reply->connectFailed.requestId = packet->requestId;
reply->connectFailed.reason = TraversalConnectFailedNoSuchClient; reply->connectFailed.reason = TraversalConnectFailedReason::NoSuchClient;
} }
else else
{ {
TraversalPacket* please = AllocPacket(MakeSinAddr(*r.value), packet->requestId); TraversalPacket* please = AllocPacket(MakeSinAddr(*r.value), packet->requestId);
please->type = TraversalPacketPleaseSendPacket; please->type = TraversalPacketType::PleaseSendPacket;
please->pleaseSendPacket.address = MakeInetAddress(*addr); please->pleaseSendPacket.address = MakeInetAddress(*addr);
} }
break; break;
} }
default: default:
fprintf(stderr, "received unknown packet type %d from %s\n", packet->type, SenderName(addr)); fprintf(stderr, "received unknown packet type %d from %s\n", static_cast<int>(packet->type),
SenderName(addr));
break;
} }
if (packet->type != TraversalPacketAck) if (packet->type != TraversalPacketType::Ack)
{ {
TraversalPacket ack = {}; TraversalPacket ack = {};
ack.type = TraversalPacketAck; ack.type = TraversalPacketType::Ack;
ack.requestId = packet->requestId; ack.requestId = packet->requestId;
ack.ack.ok = packetOk; ack.ack.ok = packetOk;
TrySend(&ack, sizeof(ack), addr); TrySend(&ack, sizeof(ack), addr);

View File

@ -174,7 +174,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay
m_traversal_client = g_TraversalClient.get(); m_traversal_client = g_TraversalClient.get();
// If we were disconnected in the background, reconnect. // If we were disconnected in the background, reconnect.
if (m_traversal_client->GetState() == TraversalClient::Failure) if (m_traversal_client->HasFailed())
m_traversal_client->ReconnectToServer(); m_traversal_client->ReconnectToServer();
m_traversal_client->m_Client = this; m_traversal_client->m_Client = this;
m_host_spec = address; m_host_spec = address;
@ -1755,12 +1755,13 @@ void NetPlayClient::OnTraversalStateChanged()
const TraversalClient::State state = m_traversal_client->GetState(); const TraversalClient::State state = m_traversal_client->GetState();
if (m_connection_state == ConnectionState::WaitingForTraversalClientConnection && if (m_connection_state == ConnectionState::WaitingForTraversalClientConnection &&
state == TraversalClient::Connected) state == TraversalClient::State::Connected)
{ {
m_connection_state = ConnectionState::WaitingForTraversalClientConnectReady; m_connection_state = ConnectionState::WaitingForTraversalClientConnectReady;
m_traversal_client->ConnectToClient(m_host_spec); m_traversal_client->ConnectToClient(m_host_spec);
} }
else if (m_connection_state != ConnectionState::Failure && state == TraversalClient::Failure) else if (m_connection_state != ConnectionState::Failure &&
state == TraversalClient::State::Failure)
{ {
Disconnect(); Disconnect();
m_dialog->OnTraversalError(m_traversal_client->GetFailureReason()); m_dialog->OnTraversalError(m_traversal_client->GetFailureReason());
@ -1779,19 +1780,19 @@ void NetPlayClient::OnConnectReady(ENetAddress addr)
} }
// called from ---NETPLAY--- thread // called from ---NETPLAY--- thread
void NetPlayClient::OnConnectFailed(u8 reason) void NetPlayClient::OnConnectFailed(TraversalConnectFailedReason reason)
{ {
m_connecting = false; m_connecting = false;
m_connection_state = ConnectionState::Failure; m_connection_state = ConnectionState::Failure;
switch (reason) switch (reason)
{ {
case TraversalConnectFailedClientDidntRespond: case TraversalConnectFailedReason::ClientDidntRespond:
PanicAlertFmtT("Traversal server timed out connecting to the host"); PanicAlertFmtT("Traversal server timed out connecting to the host");
break; break;
case TraversalConnectFailedClientFailure: case TraversalConnectFailedReason::ClientFailure:
PanicAlertFmtT("Server rejected traversal attempt"); PanicAlertFmtT("Server rejected traversal attempt");
break; break;
case TraversalConnectFailedNoSuchClient: case TraversalConnectFailedReason::NoSuchClient:
PanicAlertFmtT("Invalid host"); PanicAlertFmtT("Invalid host");
break; break;
default: default:

View File

@ -125,7 +125,7 @@ public:
void OnTraversalStateChanged() override; void OnTraversalStateChanged() override;
void OnConnectReady(ENetAddress addr) override; void OnConnectReady(ENetAddress addr) override;
void OnConnectFailed(u8 reason) override; void OnConnectFailed(TraversalConnectFailedReason reason) override;
bool IsFirstInGamePad(int ingame_pad) const; bool IsFirstInGamePad(int ingame_pad) const;
int NumLocalPads() const; int NumLocalPads() const;

View File

@ -126,7 +126,7 @@ NetPlayServer::NetPlayServer(const u16 port, const bool forward_port, NetPlayUI*
m_server = g_MainNetHost.get(); m_server = g_MainNetHost.get();
if (g_TraversalClient->GetState() == TraversalClient::Failure) if (g_TraversalClient->HasFailed())
g_TraversalClient->ReconnectToServer(); g_TraversalClient->ReconnectToServer();
} }
else else
@ -190,7 +190,7 @@ void NetPlayServer::SetupIndex()
if (m_traversal_client) if (m_traversal_client)
{ {
if (m_traversal_client->GetState() != TraversalClient::Connected) if (!m_traversal_client->IsConnected())
return; return;
session.server_id = std::string(g_TraversalClient->GetHostID().data(), 8); session.server_id = std::string(g_TraversalClient->GetHostID().data(), 8);
@ -1149,7 +1149,7 @@ void NetPlayServer::OnTraversalStateChanged()
if (!m_dialog) if (!m_dialog)
return; return;
if (state == TraversalClient::Failure) if (state == TraversalClient::State::Failure)
m_dialog->OnTraversalError(m_traversal_client->GetFailureReason()); m_dialog->OnTraversalError(m_traversal_client->GetFailureReason());
m_dialog->OnTraversalStateChanged(state); m_dialog->OnTraversalStateChanged(state);

View File

@ -134,7 +134,7 @@ private:
void OnTraversalStateChanged() override; void OnTraversalStateChanged() override;
void OnConnectReady(ENetAddress) override {} void OnConnectReady(ENetAddress) override {}
void OnConnectFailed(u8) override {} void OnConnectFailed(TraversalConnectFailedReason) override {}
void UpdatePadMapping(); void UpdatePadMapping();
void UpdateWiimoteMapping(); void UpdateWiimoteMapping();
std::vector<std::pair<std::string, std::string>> GetInterfaceListInternal() const; std::vector<std::pair<std::string, std::string>> GetInterfaceListInternal() const;

View File

@ -711,11 +711,11 @@ void NetPlayDialog::UpdateGUI()
{ {
switch (g_TraversalClient->GetState()) switch (g_TraversalClient->GetState())
{ {
case TraversalClient::Connecting: case TraversalClient::State::Connecting:
m_hostcode_label->setText(tr("...")); m_hostcode_label->setText(tr("..."));
m_hostcode_action_button->setEnabled(false); m_hostcode_action_button->setEnabled(false);
break; break;
case TraversalClient::Connected: case TraversalClient::State::Connected:
{ {
const auto host_id = g_TraversalClient->GetHostID(); const auto host_id = g_TraversalClient->GetHostID();
m_hostcode_label->setText( m_hostcode_label->setText(
@ -725,7 +725,7 @@ void NetPlayDialog::UpdateGUI()
m_is_copy_button_retry = false; m_is_copy_button_retry = false;
break; break;
} }
case TraversalClient::Failure: case TraversalClient::State::Failure:
m_hostcode_label->setText(tr("Error")); m_hostcode_label->setText(tr("Error"));
m_hostcode_action_button->setText(tr("Retry")); m_hostcode_action_button->setText(tr("Retry"));
m_hostcode_action_button->setEnabled(true); m_hostcode_action_button->setEnabled(true);
@ -1003,6 +1003,7 @@ void NetPlayDialog::OnTraversalStateChanged(TraversalClient::State state)
case TraversalClient::State::Connected: case TraversalClient::State::Connected:
case TraversalClient::State::Failure: case TraversalClient::State::Failure:
UpdateDiscordPresence(); UpdateDiscordPresence();
break;
default: default:
break; break;
} }