- Timestamp:
- 06/07/18 00:09:38 (7 years ago)
- Location:
- ps/trunk
- Files:
-
- 5 edited
-
binaries/data/config/default.cfg (modified) (1 diff)
-
source/network/NetClient.cpp (modified) (4 diffs)
-
source/network/NetServer.cpp (modified) (4 diffs)
-
source/network/NetSession.cpp (modified) (4 diffs)
-
source/network/NetSession.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/config/default.cfg
r21759 r21842 446 446 lateobservers = everyone ; Allow observers to join the game after it started. Possible values: everyone, buddies, disabled. 447 447 observerlimit = 8 ; Prevent further observer joins in running games if this limit is reached 448 gamestarttimeout = 60000 ; Don't disconnect clients timing out in the loading screen and rejoin process before exceeding this timeout. 448 449 449 450 [overlay] -
ps/trunk/source/network/NetClient.cpp
r21837 r21842 673 673 } 674 674 675 // This is called either when the host clicks the StartGame button or 676 // if this client rejoins and finishes the download of the simstate. 675 677 bool CNetClient::OnGameStart(void* context, CFsmEvent* event) 676 678 { … … 680 682 JSContext* cx = client->GetScriptInterface().GetContext(); 681 683 JSAutoRequest rq(cx); 684 685 client->m_Session->SetLongTimeout(true); 682 686 683 687 // Find the player assigned to our GUID … … 821 825 CClientsLoadingMessage* message = (CClientsLoadingMessage*)event->GetParamRef(); 822 826 827 CNetClient* client = (CNetClient*)context; 828 JSContext* cx = client->GetScriptInterface().GetContext(); 829 JSAutoRequest rq(cx); 830 831 bool finished = true; 823 832 std::vector<CStr> guids; 824 833 guids.reserve(message->m_Clients.size()); 825 for (const CClientsLoadingMessage::S_m_Clients& client : message->m_Clients) 826 guids.push_back(client.m_GUID); 827 828 CNetClient* client = (CNetClient*)context; 829 JSContext* cx = client->GetScriptInterface().GetContext(); 830 JSAutoRequest rq(cx); 834 for (const CClientsLoadingMessage::S_m_Clients& mClient : message->m_Clients) 835 { 836 if (client->m_GUID == mClient.m_GUID) 837 finished = false; 838 839 guids.push_back(mClient.m_GUID); 840 } 841 842 // Disable the timeout here after processing the enet message, so as to ensure that the connection isn't currently 843 // timing out (as it is when just leaving the loading screen in LoadFinished). 844 if (finished) 845 client->m_Session->SetLongTimeout(false); 831 846 832 847 JS::RootedValue msg(cx); … … 875 890 if (client->m_Rejoin) 876 891 client->SendRejoinedMessage(); 892 893 // The last client to leave the loading screen didn't receive the CClientsLoadingMessage, so disable here. 894 client->m_Session->SetLongTimeout(false); 877 895 878 896 return true; -
ps/trunk/source/network/NetServer.cpp
r21836 r21842 1096 1096 // the most efficient client to request a copy from 1097 1097 CNetServerSession* sourceSession = server.m_Sessions.at(0); 1098 1099 session->SetLongTimeout(true); 1100 1098 1101 sourceSession->GetFileTransferer().StartTask( 1099 1102 shared_ptr<CNetFileReceiveTask>(new CNetFileReceiveTask_ServerRejoin(server, newHostID)) … … 1264 1267 CNetServerWorker& server = loadedSession->GetServer(); 1265 1268 1269 loadedSession->SetLongTimeout(false); 1270 1266 1271 // We're in the loading state, so wait until every client has loaded 1267 1272 // before starting the game … … 1361 1366 } 1362 1367 1368 session->SetLongTimeout(false); 1369 1363 1370 return true; 1364 1371 } … … 1451 1458 m_ServerTurnManager = new CNetServerTurnManager(*this); 1452 1459 1453 for (const CNetServerSession* session : m_Sessions) 1460 for (CNetServerSession* session : m_Sessions) 1461 { 1454 1462 m_ServerTurnManager->InitialiseClient(session->GetHostID(), 0); // TODO: only for non-observers 1463 session->SetLongTimeout(true); 1464 } 1455 1465 1456 1466 m_State = SERVER_STATE_LOADING; -
ps/trunk/source/network/NetSession.cpp
r21841 r21842 24 24 #include "lib/external_libraries/enet.h" 25 25 #include "ps/CLogger.h" 26 #include "ps/ConfigDB.h" 26 27 #include "ps/Profile.h" 27 28 #include "scriptinterface/ScriptInterface.h" … … 32 33 33 34 static const int CHANNEL_COUNT = 1; 35 36 // Only disable long timeouts after a packet from the remote enet peer has been processed. 37 // Otherwise a long timeout can still be in progress when disabling it here. 38 void SetEnetLongTimeout(ENetPeer* peer, bool isLocalClient, bool enabled) 39 { 40 #if (ENET_VERSION >= ENET_VERSION_CREATE(1, 3, 4)) 41 if (!peer || isLocalClient) 42 return; 43 44 if (enabled) 45 { 46 u32 timeout; 47 CFG_GET_VAL("network.gamestarttimeout", timeout); 48 enet_peer_timeout(peer, 0, timeout, timeout); 49 } 50 else 51 enet_peer_timeout(peer, 0, 0, 0); 52 #endif 53 } 34 54 35 55 CNetClientSession::CNetClientSession(CNetClient& client) : … … 202 222 } 203 223 224 void CNetClientSession::SetLongTimeout(bool enabled) 225 { 226 SetEnetLongTimeout(m_Server, m_IsLocalClient, enabled); 227 } 228 204 229 CNetServerSession::CNetServerSession(CNetServerWorker& server, ENetPeer* peer) : 205 230 m_Server(server), m_FileTransferer(this), m_Peer(peer), m_IsLocalClient(false), m_HostID(0), m_GUID(), m_UserName() … … 262 287 #endif 263 288 } 289 290 void CNetServerSession::SetLongTimeout(bool enabled) 291 { 292 SetEnetLongTimeout(m_Peer, m_IsLocalClient, enabled); 293 } -
ps/trunk/source/network/NetSession.h
r21841 r21842 106 106 u32 GetMeanRTT() const; 107 107 108 /** 109 * Allows increasing the timeout to prevent drops during an expensive operation, 110 * and decreasing it back to normal afterwards. 111 */ 112 void SetLongTimeout(bool longTimeout); 113 108 114 CNetFileTransferer& GetFileTransferer() { return m_FileTransferer; } 109 115 … … 185 191 186 192 /** 193 * Allows increasing the timeout to prevent drops during an expensive operation, 194 * and decreasing it back to normal afterwards. 195 */ 196 void SetLongTimeout(bool longTimeout); 197 198 /** 187 199 * Send a message to the client. 188 200 */
Note:
See TracChangeset
for help on using the changeset viewer.
