mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 17:23:58 +00:00
Compare commits
1 Commits
a9b57fc1b7
...
v4.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
518c04fdb4 |
@@ -8,6 +8,7 @@ public static class CallGSRouter
|
|||||||
{
|
{
|
||||||
private static readonly Logger Logger = new("CallGS");
|
private static readonly Logger Logger = new("CallGS");
|
||||||
private static readonly Dictionary<string, ICallGSHandler> Handlers = [];
|
private static readonly Dictionary<string, ICallGSHandler> Handlers = [];
|
||||||
|
private const string UnavailableTipKey = "ui.TxtNotOpen";
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
@@ -32,11 +33,13 @@ public static class CallGSRouter
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error($"[{req.Api}] {e.Message}", e);
|
Logger.Error($"[{req.Api}] {e.Message}", e);
|
||||||
|
await SendUnavailableResponse(connection, req.Api);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Error($"No handler for CallGS API: {req.Api}");
|
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!)
|
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 };
|
var rsp = new NtfCallScript { Api = api, Arg = arg, ExtraSync = extra };
|
||||||
await connection.SendPacket(CmdIds.NtfScript, rsp);
|
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}}"}""");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v=4.4
|
v=4.5
|
||||||
Reference in New Issue
Block a user