Merge pull request #11791 from lioncash/traverse

Common/Traversal: Move interface into Common namespace
This commit is contained in:
Léo Lam 2023-04-25 01:05:41 +01:00 committed by GitHub
commit 77b334b47b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 127 additions and 105 deletions

View File

@ -12,6 +12,8 @@
#include "Common/Random.h"
#include "Core/NetPlayProto.h"
namespace Common
{
TraversalClient::TraversalClient(ENetHost* netHost, const std::string& server, const u16 port)
: m_NetHost(netHost), m_Server(server), m_port(port)
{
@ -304,7 +306,7 @@ int ENET_CALLBACK TraversalClient::InterceptCallback(ENetHost* host, ENetEvent*
}
std::unique_ptr<TraversalClient> g_TraversalClient;
Common::ENet::ENetHostPtr g_MainNetHost;
ENet::ENetHostPtr g_MainNetHost;
// The settings at the previous TraversalClient reset - notably, we
// need to know not just what port it's on, but whether it was
@ -348,3 +350,4 @@ void ReleaseTraversalClient()
g_TraversalClient.reset();
g_MainNetHost.reset();
}
} // namespace Common

View File

@ -15,6 +15,8 @@
#include "Common/Thread.h"
#include "Common/TraversalProto.h"
namespace Common
{
class TraversalClientClient
{
public:
@ -90,9 +92,12 @@ private:
u16 m_port;
u32 m_PingTime = 0;
};
extern std::unique_ptr<TraversalClient> g_TraversalClient;
// the NetHost connected to the TraversalClient.
extern Common::ENet::ENetHostPtr g_MainNetHost;
extern ENet::ENetHostPtr g_MainNetHost;
// Create g_TraversalClient and g_MainNetHost if necessary.
bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 listen_port = 0);
void ReleaseTraversalClient();
} // namespace Common

View File

@ -6,6 +6,8 @@
#include <cstddef>
#include "Common/CommonTypes.h"
namespace Common
{
constexpr size_t NETPLAY_CODE_SIZE = 8;
using TraversalHostId = std::array<char, NETPLAY_CODE_SIZE>;
using TraversalRequestId = u64;
@ -92,3 +94,4 @@ struct TraversalPacket
};
};
#pragma pack(pop)
} // namespace Common

View File

@ -31,8 +31,8 @@ static u64 currentTime;
struct OutgoingPacketInfo
{
TraversalPacket packet;
TraversalRequestId misc;
Common::TraversalPacket packet;
Common::TraversalRequestId misc;
sockaddr_in6 dest;
int tries;
u64 sendTime;
@ -104,9 +104,9 @@ V* EvictSet(std::unordered_map<K, EvictEntry<V>>& map, const K& key)
namespace std
{
template <>
struct hash<TraversalHostId>
struct hash<Common::TraversalHostId>
{
size_t operator()(const TraversalHostId& id) const
size_t operator()(const Common::TraversalHostId& id) const noexcept
{
auto p = (u32*)id.data();
return p[0] ^ ((p[1] << 13) | (p[1] >> 19));
@ -114,11 +114,15 @@ struct hash<TraversalHostId>
};
} // namespace std
static int sock;
static std::unordered_map<TraversalRequestId, OutgoingPacketInfo> outgoingPackets;
static std::unordered_map<TraversalHostId, EvictEntry<TraversalInetAddress>> connectedClients;
using ConnectedClients =
std::unordered_map<Common::TraversalHostId, EvictEntry<Common::TraversalInetAddress>>;
using OutgoingPackets = std::unordered_map<Common::TraversalRequestId, OutgoingPacketInfo>;
static TraversalInetAddress MakeInetAddress(const sockaddr_in6& addr)
static int sock;
static OutgoingPackets outgoingPackets;
static ConnectedClients connectedClients;
static Common::TraversalInetAddress MakeInetAddress(const sockaddr_in6& addr)
{
if (addr.sin6_family != AF_INET6)
{
@ -126,7 +130,7 @@ static TraversalInetAddress MakeInetAddress(const sockaddr_in6& addr)
exit(1);
}
u32* words = (u32*)addr.sin6_addr.s6_addr;
TraversalInetAddress result = {0};
Common::TraversalInetAddress result = {};
if (words[0] == 0 && words[1] == 0 && words[2] == 0xffff0000)
{
result.isIPV6 = false;
@ -141,7 +145,7 @@ static TraversalInetAddress MakeInetAddress(const sockaddr_in6& addr)
return result;
}
static sockaddr_in6 MakeSinAddr(const TraversalInetAddress& addr)
static sockaddr_in6 MakeSinAddr(const Common::TraversalInetAddress& addr)
{
sockaddr_in6 result;
#ifdef SIN6_LEN
@ -166,7 +170,7 @@ static sockaddr_in6 MakeSinAddr(const TraversalInetAddress& addr)
return result;
}
static void GetRandomHostId(TraversalHostId* hostId)
static void GetRandomHostId(Common::TraversalHostId* hostId)
{
char buf[9];
const u32 num = Common::Random::GenerateValue<u32>();
@ -185,7 +189,7 @@ static const char* SenderName(sockaddr_in6* addr)
static void TrySend(const void* buffer, size_t size, sockaddr_in6* addr)
{
#if DEBUG
const auto* packet = static_cast<const TraversalPacket*>(buffer);
const auto* packet = static_cast<const Common::TraversalPacket*>(buffer);
printf("-> %d %llu %s\n", static_cast<int>(packet->type),
static_cast<long long>(packet->requestId), SenderName(addr));
#endif
@ -195,16 +199,17 @@ static void TrySend(const void* buffer, size_t size, sockaddr_in6* addr)
}
}
static TraversalPacket* AllocPacket(const sockaddr_in6& dest, TraversalRequestId misc = 0)
static Common::TraversalPacket* AllocPacket(const sockaddr_in6& dest,
Common::TraversalRequestId misc = 0)
{
TraversalRequestId requestId;
Common::TraversalRequestId requestId{};
Common::Random::Generate(&requestId, sizeof(requestId));
OutgoingPacketInfo* info = &outgoingPackets[requestId];
info->dest = dest;
info->misc = misc;
info->tries = 0;
info->sendTime = currentTime;
TraversalPacket* result = &info->packet;
Common::TraversalPacket* result = &info->packet;
memset(result, 0, sizeof(*result));
result->requestId = requestId;
return result;
@ -219,7 +224,7 @@ static void SendPacket(OutgoingPacketInfo* info)
static void ResendPackets()
{
std::vector<std::pair<TraversalInetAddress, TraversalRequestId>> todoFailures;
std::vector<std::pair<Common::TraversalInetAddress, Common::TraversalRequestId>> todoFailures;
todoFailures.clear();
for (auto it = outgoingPackets.begin(); it != outgoingPackets.end();)
{
@ -228,7 +233,7 @@ static void ResendPackets()
{
if (info->tries >= NUMBER_OF_TRIES)
{
if (info->packet.type == TraversalPacketType::PleaseSendPacket)
if (info->packet.type == Common::TraversalPacketType::PleaseSendPacket)
{
todoFailures.push_back(std::make_pair(info->packet.pleaseSendPacket.address, info->misc));
}
@ -245,14 +250,14 @@ static void ResendPackets()
for (const auto& p : todoFailures)
{
TraversalPacket* fail = AllocPacket(MakeSinAddr(p.first));
fail->type = TraversalPacketType::ConnectFailed;
Common::TraversalPacket* fail = AllocPacket(MakeSinAddr(p.first));
fail->type = Common::TraversalPacketType::ConnectFailed;
fail->connectFailed.requestId = p.second;
fail->connectFailed.reason = TraversalConnectFailedReason::ClientDidntRespond;
fail->connectFailed.reason = Common::TraversalConnectFailedReason::ClientDidntRespond;
}
}
static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
static void HandlePacket(Common::TraversalPacket* packet, sockaddr_in6* addr)
{
#if DEBUG
printf("<- %d %llu %s\n", static_cast<int>(packet->type),
@ -261,7 +266,7 @@ static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
bool packetOk = true;
switch (packet->type)
{
case TraversalPacketType::Ack:
case Common::TraversalPacketType::Ack:
{
auto it = outgoingPackets.find(packet->requestId);
if (it == outgoingPackets.end())
@ -269,42 +274,42 @@ static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
OutgoingPacketInfo* info = &it->second;
if (info->packet.type == TraversalPacketType::PleaseSendPacket)
if (info->packet.type == Common::TraversalPacketType::PleaseSendPacket)
{
TraversalPacket* ready = AllocPacket(MakeSinAddr(info->packet.pleaseSendPacket.address));
auto* ready = AllocPacket(MakeSinAddr(info->packet.pleaseSendPacket.address));
if (packet->ack.ok)
{
ready->type = TraversalPacketType::ConnectReady;
ready->type = Common::TraversalPacketType::ConnectReady;
ready->connectReady.requestId = info->misc;
ready->connectReady.address = MakeInetAddress(info->dest);
}
else
{
ready->type = TraversalPacketType::ConnectFailed;
ready->type = Common::TraversalPacketType::ConnectFailed;
ready->connectFailed.requestId = info->misc;
ready->connectFailed.reason = TraversalConnectFailedReason::ClientFailure;
ready->connectFailed.reason = Common::TraversalConnectFailedReason::ClientFailure;
}
}
outgoingPackets.erase(it);
break;
}
case TraversalPacketType::Ping:
case Common::TraversalPacketType::Ping:
{
auto r = EvictFind(connectedClients, packet->ping.hostId, true);
packetOk = r.found;
break;
}
case TraversalPacketType::HelloFromClient:
case Common::TraversalPacketType::HelloFromClient:
{
u8 ok = packet->helloFromClient.protoVersion <= TraversalProtoVersion;
TraversalPacket* reply = AllocPacket(*addr);
reply->type = TraversalPacketType::HelloFromServer;
u8 ok = packet->helloFromClient.protoVersion <= Common::TraversalProtoVersion;
Common::TraversalPacket* reply = AllocPacket(*addr);
reply->type = Common::TraversalPacketType::HelloFromServer;
reply->helloFromServer.ok = ok;
if (ok)
{
TraversalHostId hostId;
TraversalInetAddress* iaddr;
Common::TraversalHostId hostId{};
Common::TraversalInetAddress* iaddr{};
// not that there is any significant change of
// duplication, but...
GetRandomHostId(&hostId);
@ -325,21 +330,21 @@ static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
}
break;
}
case TraversalPacketType::ConnectPlease:
case Common::TraversalPacketType::ConnectPlease:
{
TraversalHostId& hostId = packet->connectPlease.hostId;
Common::TraversalHostId& hostId = packet->connectPlease.hostId;
auto r = EvictFind(connectedClients, hostId);
if (!r.found)
{
TraversalPacket* reply = AllocPacket(*addr);
reply->type = TraversalPacketType::ConnectFailed;
Common::TraversalPacket* reply = AllocPacket(*addr);
reply->type = Common::TraversalPacketType::ConnectFailed;
reply->connectFailed.requestId = packet->requestId;
reply->connectFailed.reason = TraversalConnectFailedReason::NoSuchClient;
reply->connectFailed.reason = Common::TraversalConnectFailedReason::NoSuchClient;
}
else
{
TraversalPacket* please = AllocPacket(MakeSinAddr(*r.value), packet->requestId);
please->type = TraversalPacketType::PleaseSendPacket;
Common::TraversalPacket* please = AllocPacket(MakeSinAddr(*r.value), packet->requestId);
please->type = Common::TraversalPacketType::PleaseSendPacket;
please->pleaseSendPacket.address = MakeInetAddress(*addr);
}
break;
@ -349,10 +354,10 @@ static void HandlePacket(TraversalPacket* packet, sockaddr_in6* addr)
SenderName(addr));
break;
}
if (packet->type != TraversalPacketType::Ack)
if (packet->type != Common::TraversalPacketType::Ack)
{
TraversalPacket ack = {};
ack.type = TraversalPacketType::Ack;
Common::TraversalPacket ack = {};
ack.type = Common::TraversalPacketType::Ack;
ack.requestId = packet->requestId;
ack.ack.ok = packetOk;
TrySend(&ack, sizeof(ack), addr);
@ -411,7 +416,7 @@ int main()
{
sockaddr_in6 raddr;
socklen_t addrLen = sizeof(raddr);
TraversalPacket packet;
Common::TraversalPacket packet{};
// note: switch to recvmmsg (yes, mmsg) if this becomes
// expensive
rv = recvfrom(sock, &packet, sizeof(packet), 0, (sockaddr*)&raddr, &addrLen);

View File

@ -110,9 +110,9 @@ NetPlayClient::~NetPlayClient()
Disconnect();
}
if (g_MainNetHost.get() == m_client)
if (Common::g_MainNetHost.get() == m_client)
{
g_MainNetHost.release();
Common::g_MainNetHost.release();
}
if (m_client)
{
@ -122,7 +122,7 @@ NetPlayClient::~NetPlayClient()
if (m_traversal_client)
{
ReleaseTraversalClient();
Common::ReleaseTraversalClient();
}
}
@ -179,18 +179,21 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay
}
else
{
if (address.size() > NETPLAY_CODE_SIZE)
if (address.size() > Common::NETPLAY_CODE_SIZE)
{
m_dialog->OnConnectionError(
_trans("The host code is too long.\nPlease recheck that you have the correct code."));
return;
}
if (!EnsureTraversalClient(traversal_config.traversal_host, traversal_config.traversal_port))
if (!Common::EnsureTraversalClient(traversal_config.traversal_host,
traversal_config.traversal_port))
{
return;
m_client = g_MainNetHost.get();
}
m_client = Common::g_MainNetHost.get();
m_traversal_client = g_TraversalClient.get();
m_traversal_client = Common::g_TraversalClient.get();
// If we were disconnected in the background, reconnect.
if (m_traversal_client->HasFailed())
@ -1936,16 +1939,16 @@ void NetPlayClient::ClearBuffers()
// called from ---NETPLAY--- thread
void NetPlayClient::OnTraversalStateChanged()
{
const TraversalClient::State state = m_traversal_client->GetState();
const Common::TraversalClient::State state = m_traversal_client->GetState();
if (m_connection_state == ConnectionState::WaitingForTraversalClientConnection &&
state == TraversalClient::State::Connected)
state == Common::TraversalClient::State::Connected)
{
m_connection_state = ConnectionState::WaitingForTraversalClientConnectReady;
m_traversal_client->ConnectToClient(m_host_spec);
}
else if (m_connection_state != ConnectionState::Failure &&
state == TraversalClient::State::Failure)
state == Common::TraversalClient::State::Failure)
{
Disconnect();
m_dialog->OnTraversalError(m_traversal_client->GetFailureReason());
@ -1964,19 +1967,19 @@ void NetPlayClient::OnConnectReady(ENetAddress addr)
}
// called from ---NETPLAY--- thread
void NetPlayClient::OnConnectFailed(TraversalConnectFailedReason reason)
void NetPlayClient::OnConnectFailed(Common::TraversalConnectFailedReason reason)
{
m_connecting = false;
m_connection_state = ConnectionState::Failure;
switch (reason)
{
case TraversalConnectFailedReason::ClientDidntRespond:
case Common::TraversalConnectFailedReason::ClientDidntRespond:
PanicAlertFmtT("Traversal server timed out connecting to the host");
break;
case TraversalConnectFailedReason::ClientFailure:
case Common::TraversalConnectFailedReason::ClientFailure:
PanicAlertFmtT("Server rejected traversal attempt");
break;
case TraversalConnectFailedReason::NoSuchClient:
case Common::TraversalConnectFailedReason::NoSuchClient:
PanicAlertFmtT("Invalid host");
break;
default:

View File

@ -68,8 +68,8 @@ public:
virtual void OnDesync(u32 frame, const std::string& player) = 0;
virtual void OnConnectionLost() = 0;
virtual void OnConnectionError(const std::string& message) = 0;
virtual void OnTraversalError(TraversalClient::FailureReason error) = 0;
virtual void OnTraversalStateChanged(TraversalClient::State state) = 0;
virtual void OnTraversalError(Common::TraversalClient::FailureReason error) = 0;
virtual void OnTraversalStateChanged(Common::TraversalClient::State state) = 0;
virtual void OnGameStartAborted() = 0;
virtual void OnGolferChanged(bool is_golfer, const std::string& golfer_name) = 0;
@ -107,7 +107,7 @@ public:
bool IsHost() const { return pid == 1; }
};
class NetPlayClient : public TraversalClientClient
class NetPlayClient : public Common::TraversalClientClient
{
public:
void ThreadFunc();
@ -147,7 +147,7 @@ public:
void OnTraversalStateChanged() override;
void OnConnectReady(ENetAddress addr) override;
void OnConnectFailed(TraversalConnectFailedReason reason) override;
void OnConnectFailed(Common::TraversalConnectFailedReason reason) override;
bool IsFirstInGamePad(int ingame_pad) const;
int NumLocalPads() const;
@ -325,7 +325,7 @@ private:
std::string m_host_spec;
std::string m_player_name;
bool m_connecting = false;
TraversalClient* m_traversal_client = nullptr;
Common::TraversalClient* m_traversal_client = nullptr;
std::thread m_game_digest_thread;
bool m_should_compute_game_digest = false;
Common::Event m_gc_pad_event;

View File

@ -98,15 +98,15 @@ NetPlayServer::~NetPlayServer()
m_thread.join();
enet_host_destroy(m_server);
if (g_MainNetHost.get() == m_server)
if (Common::g_MainNetHost.get() == m_server)
{
g_MainNetHost.release();
Common::g_MainNetHost.release();
}
if (m_traversal_client)
{
g_TraversalClient->m_Client = nullptr;
ReleaseTraversalClient();
Common::g_TraversalClient->m_Client = nullptr;
Common::ReleaseTraversalClient();
}
}
@ -132,17 +132,19 @@ NetPlayServer::NetPlayServer(const u16 port, const bool forward_port, NetPlayUI*
if (traversal_config.use_traversal)
{
if (!EnsureTraversalClient(traversal_config.traversal_host, traversal_config.traversal_port,
port))
if (!Common::EnsureTraversalClient(traversal_config.traversal_host,
traversal_config.traversal_port, port))
{
return;
}
g_TraversalClient->m_Client = this;
m_traversal_client = g_TraversalClient.get();
Common::g_TraversalClient->m_Client = this;
m_traversal_client = Common::g_TraversalClient.get();
m_server = g_MainNetHost.get();
m_server = Common::g_MainNetHost.get();
if (g_TraversalClient->HasFailed())
g_TraversalClient->ReconnectToServer();
if (Common::g_TraversalClient->HasFailed())
Common::g_TraversalClient->ReconnectToServer();
}
else
{
@ -211,7 +213,7 @@ void NetPlayServer::SetupIndex()
if (!m_traversal_client->IsConnected())
return;
session.server_id = std::string(g_TraversalClient->GetHostID().data(), 8);
session.server_id = std::string(Common::g_TraversalClient->GetHostID().data(), 8);
}
else
{
@ -1248,15 +1250,15 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
void NetPlayServer::OnTraversalStateChanged()
{
const TraversalClient::State state = m_traversal_client->GetState();
const Common::TraversalClient::State state = m_traversal_client->GetState();
if (g_TraversalClient->GetHostID()[0] != '\0')
if (Common::g_TraversalClient->GetHostID()[0] != '\0')
SetupIndex();
if (!m_dialog)
return;
if (state == TraversalClient::State::Failure)
if (state == Common::TraversalClient::State::Failure)
m_dialog->OnTraversalError(m_traversal_client->GetFailureReason());
m_dialog->OnTraversalStateChanged(state);

View File

@ -31,7 +31,7 @@ namespace NetPlay
class NetPlayUI;
struct SaveSyncInfo;
class NetPlayServer : public TraversalClientClient
class NetPlayServer : public Common::TraversalClientClient
{
public:
void ThreadFunc();
@ -143,7 +143,7 @@ private:
void OnTraversalStateChanged() override;
void OnConnectReady(ENetAddress) override {}
void OnConnectFailed(TraversalConnectFailedReason) override {}
void OnConnectFailed(Common::TraversalConnectFailedReason) override {}
void UpdatePadMapping();
void UpdateGBAConfig();
void UpdateWiimoteMapping();
@ -210,7 +210,7 @@ private:
bool m_abort_chunked_data = false;
ENetHost* m_server = nullptr;
TraversalClient* m_traversal_client = nullptr;
Common::TraversalClient* m_traversal_client = nullptr;
NetPlayUI* m_dialog = nullptr;
NetPlayIndex m_index;
};

View File

@ -65,7 +65,7 @@
namespace
{
QString InetAddressToString(const TraversalInetAddress& addr)
QString InetAddressToString(const Common::TraversalInetAddress& addr)
{
QString ip;
@ -321,7 +321,7 @@ void NetPlayDialog::ConnectWidgets()
&NetPlayDialog::UpdateGUI);
connect(m_hostcode_action_button, &QPushButton::clicked, [this] {
if (m_is_copy_button_retry)
g_TraversalClient->ReconnectToServer();
Common::g_TraversalClient->ReconnectToServer();
else
QApplication::clipboard()->setText(m_hostcode_label->text());
});
@ -581,9 +581,9 @@ void NetPlayDialog::UpdateDiscordPresence()
if (IsHosting())
{
if (g_TraversalClient)
if (Common::g_TraversalClient)
{
const auto host_id = g_TraversalClient->GetHostID();
const auto host_id = Common::g_TraversalClient->GetHostID();
if (host_id[0] == '\0')
return use_default();
@ -706,26 +706,27 @@ void NetPlayDialog::UpdateGUI()
}
else if (m_use_traversal)
{
switch (g_TraversalClient->GetState())
switch (Common::g_TraversalClient->GetState())
{
case TraversalClient::State::Connecting:
case Common::TraversalClient::State::Connecting:
m_hostcode_label->setText(tr("Connecting"));
m_hostcode_action_button->setEnabled(false);
m_hostcode_action_button->setText(tr("..."));
break;
case TraversalClient::State::Connected:
case Common::TraversalClient::State::Connected:
{
if (m_room_box->currentIndex() == 0)
{
// Display Room ID.
const auto host_id = g_TraversalClient->GetHostID();
const auto host_id = Common::g_TraversalClient->GetHostID();
m_hostcode_label->setText(
QString::fromStdString(std::string(host_id.begin(), host_id.end())));
}
else
{
// Externally mapped IP and port are known when using the traversal server.
m_hostcode_label->setText(InetAddressToString(g_TraversalClient->GetExternalAddress()));
m_hostcode_label->setText(
InetAddressToString(Common::g_TraversalClient->GetExternalAddress()));
}
m_hostcode_action_button->setEnabled(true);
@ -733,7 +734,7 @@ void NetPlayDialog::UpdateGUI()
m_is_copy_button_retry = false;
break;
}
case TraversalClient::State::Failure:
case Common::TraversalClient::State::Failure:
m_hostcode_label->setText(tr("Error"));
m_hostcode_action_button->setText(tr("Retry"));
m_hostcode_action_button->setEnabled(true);
@ -981,35 +982,35 @@ void NetPlayDialog::OnConnectionError(const std::string& message)
});
}
void NetPlayDialog::OnTraversalError(TraversalClient::FailureReason error)
void NetPlayDialog::OnTraversalError(Common::TraversalClient::FailureReason error)
{
QueueOnObject(this, [this, error] {
switch (error)
{
case TraversalClient::FailureReason::BadHost:
case Common::TraversalClient::FailureReason::BadHost:
ModalMessageBox::critical(this, tr("Traversal Error"), tr("Couldn't look up central server"));
QDialog::reject();
break;
case TraversalClient::FailureReason::VersionTooOld:
case Common::TraversalClient::FailureReason::VersionTooOld:
ModalMessageBox::critical(this, tr("Traversal Error"),
tr("Dolphin is too old for traversal server"));
QDialog::reject();
break;
case TraversalClient::FailureReason::ServerForgotAboutUs:
case TraversalClient::FailureReason::SocketSendError:
case TraversalClient::FailureReason::ResendTimeout:
case Common::TraversalClient::FailureReason::ServerForgotAboutUs:
case Common::TraversalClient::FailureReason::SocketSendError:
case Common::TraversalClient::FailureReason::ResendTimeout:
UpdateGUI();
break;
}
});
}
void NetPlayDialog::OnTraversalStateChanged(TraversalClient::State state)
void NetPlayDialog::OnTraversalStateChanged(Common::TraversalClient::State state)
{
switch (state)
{
case TraversalClient::State::Connected:
case TraversalClient::State::Failure:
case Common::TraversalClient::State::Connected:
case Common::TraversalClient::State::Failure:
UpdateDiscordPresence();
break;
default:

View File

@ -67,8 +67,8 @@ public:
void OnDesync(u32 frame, const std::string& player) override;
void OnConnectionLost() override;
void OnConnectionError(const std::string& message) override;
void OnTraversalError(TraversalClient::FailureReason error) override;
void OnTraversalStateChanged(TraversalClient::State state) override;
void OnTraversalError(Common::TraversalClient::FailureReason error) override;
void OnTraversalStateChanged(Common::TraversalClient::State state) override;
void OnGameStartAborted() override;
void OnGolferChanged(bool is_golfer, const std::string& golfer_name) override;