Skip to content

Commit df2a393

Browse files
authored
[3277] Dynamically changing the timeout for Reconnect (#3275)
Dynamically changing the timeout for Reconnect
1 parent 76e036a commit df2a393

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/main/java/com/faforever/client/game/GameRunner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ private boolean waitingForMatchMakerGame() {
373373

374374
private Process launchOnlineGame(GameParameters gameParameters, Integer gpgPort, Integer replayPort) {
375375
fafServerAccessor.setPingIntervalSeconds(5);
376+
fafServerAccessor.setTimeoutLoginReconnectSeconds(5);
376377
gameKilled = false;
377378
return forgedAllianceLaunchService.launchOnlineGame(gameParameters, gpgPort, replayPort);
378379
}
@@ -400,6 +401,7 @@ private Mono<League> getDivisionInfo(String leaderboard) {
400401

401402
private void handleTermination(Process finishedProcess) {
402403
fafServerAccessor.setPingIntervalSeconds(25);
404+
fafServerAccessor.setTimeoutLoginReconnectSeconds(30);
403405
int exitCode = finishedProcess.exitValue();
404406
log.info("Forged Alliance terminated with exit code {}", exitCode);
405407
Optional<Path> logFile = loggingService.getMostRecentGameLogFile();

src/main/java/com/faforever/client/remote/FafServerAccessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import javafx.beans.property.ReadOnlyObjectWrapper;
3636
import lombok.Getter;
3737
import lombok.RequiredArgsConstructor;
38+
import lombok.Setter;
3839
import lombok.extern.slf4j.Slf4j;
3940
import org.springframework.beans.factory.DisposableBean;
4041
import org.springframework.beans.factory.InitializingBean;
@@ -83,6 +84,9 @@ public class FafServerAccessor implements InitializingBean, DisposableBean, Life
8384
private boolean autoReconnect;
8485
@Getter
8586
private boolean running;
87+
@Getter
88+
@Setter
89+
private int timeoutLoginReconnectSeconds;
8690

8791
@Override
8892
public void afterPropertiesSet() throws Exception {
@@ -98,6 +102,7 @@ public void start() {
98102
.subscribe();
99103

100104
setPingIntervalSeconds(25);
105+
setTimeoutLoginReconnectSeconds(30);
101106

102107
lobbyClient.getConnectionStatus()
103108
.map(connectionStatus -> switch (connectionStatus) {
@@ -161,7 +166,7 @@ public Mono<Player> connectAndLogIn() {
161166
clientProperties.getUserAgent(), lobbyUrl,
162167
this::tryGenerateUid, 1024 * 1024, false)))
163168
.flatMap(lobbyClient::connectAndLogin)
164-
.timeout(Duration.ofSeconds(30))
169+
.timeout(Duration.ofSeconds(timeoutLoginReconnectSeconds))
165170
.retryWhen(createRetrySpec(clientProperties.getServer()));
166171
}
167172

src/test/java/com/faforever/client/game/GameRunnerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public void testStartOnlineGlobalGame() throws Exception {
215215
Integer uid = gameParameters.uid();
216216

217217
verify(fafServerAccessor).setPingIntervalSeconds(5);
218+
verify(fafServerAccessor).setTimeoutLoginReconnectSeconds(5);
218219
verify(leaderboardService, never()).getActiveLeagueEntryForPlayer(any(), any());
219220
verify(mapService, never()).downloadIfNecessary(any());
220221
verify(replayServer).start(uid);
@@ -234,6 +235,7 @@ public void testStartOnlineGlobalGame() throws Exception {
234235
verify(replayServer).stop();
235236
verify(fafServerAccessor).notifyGameEnded();
236237
verify(fafServerAccessor).setPingIntervalSeconds(25);
238+
verify(fafServerAccessor).setTimeoutLoginReconnectSeconds(30);
237239
verify(notificationService).addNotification(any(PersistentNotification.class));
238240
assertFalse(instance.isRunning());
239241
assertNull(instance.getRunningProcessId());

0 commit comments

Comments
 (0)