Skip to content

Commit

Permalink
NetPlay: Introduce constant for peer timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Techjar committed Mar 15, 2022
1 parent b1122ec commit 302dedb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/NetPlayClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay
}

// Extend reliable traffic timeout
enet_peer_timeout(m_server, 0, 30000, 30000);
enet_peer_timeout(m_server, 0, PEER_TIMEOUT, PEER_TIMEOUT);

ENetEvent netEvent;
int net = enet_host_service(m_client, &netEvent, 5000);
Expand Down Expand Up @@ -212,7 +212,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay
m_server = netEvent.peer;

// Extend reliable traffic timeout
enet_peer_timeout(m_server, 0, 30000, 30000);
enet_peer_timeout(m_server, 0, PEER_TIMEOUT, PEER_TIMEOUT);

if (Connect())
{
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/NetPlayCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace NetPlay
{
constexpr u32 PEER_TIMEOUT = 30000;

bool CompressFileIntoPacket(const std::string& file_path, sf::Packet& packet);
bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet);
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/NetPlayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ ConnectionError NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
return ConnectionError::NameTooLong;

// Extend reliable traffic timeout
enet_peer_timeout(socket, 0, 30000, 30000);
enet_peer_timeout(socket, 0, PEER_TIMEOUT, PEER_TIMEOUT);

// cause pings to be updated
m_update_pings = true;
Expand Down

0 comments on commit 302dedb

Please sign in to comment.