fix(multiplayer): show anti-virus software warning if cato file not found.

This commit is contained in:
huanghongxun
2021-10-10 19:02:37 +08:00
parent d89c8cc2d2
commit dc4a791a9e
5 changed files with 16 additions and 6 deletions

View File

@@ -35,10 +35,7 @@ import org.jackhuang.hmcl.util.platform.ManagedProcess;
import org.jackhuang.hmcl.util.platform.OperatingSystem;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UncheckedIOException;
import java.io.*;
import java.net.ServerSocket;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -175,7 +172,7 @@ public final class MultiplayerManager {
public static CatoSession createSession(String token, String sessionName, int gamePort, boolean allowAllJoinRequests) throws IOException {
Path exe = getCatoExecutable();
if (!Files.isRegularFile(exe)) {
throw new IllegalStateException("Cato file not found");
throw new FileNotFoundException("Cato file not found");
}
if (!isPortAvailable(3478)) {

View File

@@ -39,6 +39,7 @@ import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.FileNotFoundException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
@@ -235,9 +236,14 @@ public class MultiplayerPage extends DecoratorAnimatedPage implements DecoratorP
} catch (MultiplayerManager.CatoAlreadyStartedException e) {
LOG.log(Level.WARNING, "Cato already started", e);
reject.accept(i18n("multiplayer.session.error.already_started"));
return;
} catch (FileNotFoundException e) {
LOG.log(Level.WARNING, "Cato not found", e);
reject.accept(i18n("multiplayer.session.error.file_not_found"));
return;
} catch (Exception e) {
LOG.log(Level.WARNING, "Failed to create session", e);
reject.accept(i18n("multiplayer.session.create.error"));
reject.accept(i18n("multiplayer.session.create.error") + e.getLocalizedMessage());
return;
}
@@ -324,6 +330,10 @@ public class MultiplayerPage extends DecoratorAnimatedPage implements DecoratorP
LOG.info("Cato already started");
reject.accept(i18n("multiplayer.session.error.already_started"));
return null;
} else if (resolved instanceof FileNotFoundException) {
LOG.log(Level.WARNING, "Cato not found", resolved);
reject.accept(i18n("multiplayer.session.error.file_not_found"));
return null;
} else if (resolved instanceof MultiplayerManager.JoinRequestTimeoutException) {
LOG.info("Cato already started");
reject.accept(i18n("multiplayer.session.join.wait_timeout"));

View File

@@ -664,6 +664,7 @@ multiplayer.session.create.token=Token
multiplayer.session.create.token.apply=Apply for static token
multiplayer.session.create.token.prompt=Default randomized. You can apply for your own token at noin.cn (Chinese website).
multiplayer.session.error.already_started=Cato service has already started locally. Please check whether there are other multiplayer services served or not. Or you can kill cato process in task manager.
multiplayer.session.error.file_not_found=Cannot found cato. Please check if anti-virus software blocked our functionality.
multiplayer.session.expired=Multiplayer session has expired. You should re-create or re-join a room to continue.
multiplayer.session.hint=You must click "Open LAN Server" in game in order to enable multiplayer functionality.
multiplayer.session.join=Join Session

View File

@@ -664,6 +664,7 @@ multiplayer.session.create.token=Token
multiplayer.session.create.token.apply=申請靜態 Token
multiplayer.session.create.token.prompt=預設為臨時 Token。你可以在 noin.cn 上申請靜態 Token 並填寫至此處
multiplayer.session.error.already_started=本地已經開啟 cato 服務,請檢查是否有其他 HMCL 正在運行聯機服務。或者你可以在任務管理器裡殺掉 cato 進程以繼續。
multiplayer.session.error.file_not_found=找不到 cato。請檢查防毒軟體是否攔截了 HMCL 的多人聯機服務cato如果被攔截請取消攔截後重啟 HMCL。
multiplayer.session.expired=聯機會話連續使用時間超過了 3 小時,你需要重新創建/加入房間以繼續聯機。
multiplayer.session.join=加入房間
multiplayer.session.join.error=加入房間失敗

View File

@@ -664,6 +664,7 @@ multiplayer.session.create.token=Token
multiplayer.session.create.token.apply=申请静态 Token
multiplayer.session.create.token.prompt=默认为临时 Token。你可以在 noin.cn 上申请静态 Token 并填写至此处
multiplayer.session.error.already_started=本地已经开启 cato 服务,请检查是否有其他 HMCL 正在运行联机服务。或者你可以在任务管理器里杀掉 cato 进程以继续。
multiplayer.session.error.file_not_found=找不到 cato。请检查杀毒软件是否拦截了 HMCL 的多人联机服务cato如果被拦截请取消拦截后重启 HMCL。
multiplayer.session.expired=联机会话连续使用时间超过了 3 小时,你需要重新创建/加入房间以继续联机。
multiplayer.session.join=加入房间
multiplayer.session.join.error=加入房间失败。如果你或对方的网络类型是差(对称型),可能无法使用联机功能。