Skip to content

Commit

Permalink
[3277] Dynamically changing the timeout for Reconnect (#3275)
Browse files Browse the repository at this point in the history
Dynamically changing the timeout for Reconnect
  • Loading branch information
GodFuper authored Nov 27, 2024
1 parent 76e036a commit df2a393
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/com/faforever/client/game/GameRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ private boolean waitingForMatchMakerGame() {

private Process launchOnlineGame(GameParameters gameParameters, Integer gpgPort, Integer replayPort) {
fafServerAccessor.setPingIntervalSeconds(5);
fafServerAccessor.setTimeoutLoginReconnectSeconds(5);
gameKilled = false;
return forgedAllianceLaunchService.launchOnlineGame(gameParameters, gpgPort, replayPort);
}
Expand Down Expand Up @@ -400,6 +401,7 @@ private Mono<League> getDivisionInfo(String leaderboard) {

private void handleTermination(Process finishedProcess) {
fafServerAccessor.setPingIntervalSeconds(25);
fafServerAccessor.setTimeoutLoginReconnectSeconds(30);
int exitCode = finishedProcess.exitValue();
log.info("Forged Alliance terminated with exit code {}", exitCode);
Optional<Path> logFile = loggingService.getMostRecentGameLogFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import javafx.beans.property.ReadOnlyObjectWrapper;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
Expand Down Expand Up @@ -83,6 +84,9 @@ public class FafServerAccessor implements InitializingBean, DisposableBean, Life
private boolean autoReconnect;
@Getter
private boolean running;
@Getter
@Setter
private int timeoutLoginReconnectSeconds;

@Override
public void afterPropertiesSet() throws Exception {
Expand All @@ -98,6 +102,7 @@ public void start() {
.subscribe();

setPingIntervalSeconds(25);
setTimeoutLoginReconnectSeconds(30);

lobbyClient.getConnectionStatus()
.map(connectionStatus -> switch (connectionStatus) {
Expand Down Expand Up @@ -161,7 +166,7 @@ public Mono<Player> connectAndLogIn() {
clientProperties.getUserAgent(), lobbyUrl,
this::tryGenerateUid, 1024 * 1024, false)))
.flatMap(lobbyClient::connectAndLogin)
.timeout(Duration.ofSeconds(30))
.timeout(Duration.ofSeconds(timeoutLoginReconnectSeconds))
.retryWhen(createRetrySpec(clientProperties.getServer()));
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/faforever/client/game/GameRunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public void testStartOnlineGlobalGame() throws Exception {
Integer uid = gameParameters.uid();

verify(fafServerAccessor).setPingIntervalSeconds(5);
verify(fafServerAccessor).setTimeoutLoginReconnectSeconds(5);
verify(leaderboardService, never()).getActiveLeagueEntryForPlayer(any(), any());
verify(mapService, never()).downloadIfNecessary(any());
verify(replayServer).start(uid);
Expand All @@ -234,6 +235,7 @@ public void testStartOnlineGlobalGame() throws Exception {
verify(replayServer).stop();
verify(fafServerAccessor).notifyGameEnded();
verify(fafServerAccessor).setPingIntervalSeconds(25);
verify(fafServerAccessor).setTimeoutLoginReconnectSeconds(30);
verify(notificationService).addNotification(any(PersistentNotification.class));
assertFalse(instance.isRunning());
assertNull(instance.getRunningProcessId());
Expand Down

0 comments on commit df2a393

Please sign in to comment.