mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 04:03:58 +00:00
Fixed an issue where clicking on a feature not yet implemented on the server side would cause an infinite loading loop.
This commit is contained in:
@@ -8,6 +8,7 @@ public static class CallGSRouter
|
||||
{
|
||||
private static readonly Logger Logger = new("CallGS");
|
||||
private static readonly Dictionary<string, ICallGSHandler> Handlers = [];
|
||||
private const string UnavailableTipKey = "ui.TxtNotOpen";
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@@ -32,11 +33,13 @@ public static class CallGSRouter
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"[{req.Api}] {e.Message}", e);
|
||||
await SendUnavailableResponse(connection, req.Api);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Error($"No handler for CallGS API: {req.Api}");
|
||||
await SendUnavailableResponse(connection, req.Api);
|
||||
}
|
||||
|
||||
public static async Task SendScript(Connection connection, string api, string arg, NtfSyncPlayer extra = null!)
|
||||
@@ -44,4 +47,11 @@ public static class CallGSRouter
|
||||
var rsp = new NtfCallScript { Api = api, Arg = arg, ExtraSync = extra };
|
||||
await connection.SendPacket(CmdIds.NtfScript, rsp);
|
||||
}
|
||||
|
||||
private static Task SendUnavailableResponse(Connection connection, string api)
|
||||
{
|
||||
// Many client Lua handlers treat sErr/sError as a recoverable failure path,
|
||||
// which is preferable to leaving the request hanging forever.
|
||||
return SendScript(connection, api, $$"""{"sErr":"{{UnavailableTipKey}}","sError":"{{UnavailableTipKey}}"}""");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user