mirror of
https://github.com/milimoe/FunGame-Testing.git
synced 2025-04-21 19:59:34 +08:00
修复不同时间多客户端连接游戏模组时可能产生的线程安全问题
This commit is contained in:
parent
303c0baf9b
commit
dcbcdd17fa
@ -4,6 +4,10 @@ using Oshima.FunGame.WebAPI.Controllers;
|
|||||||
using Oshima.FunGame.OshimaModules;
|
using Oshima.FunGame.OshimaModules;
|
||||||
using Oshima.FunGame.OshimaServers.Service;
|
using Oshima.FunGame.OshimaServers.Service;
|
||||||
|
|
||||||
|
_ = new Milimoe.FunGame.Testing.Tests.CheckDLL();
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
_ = new Milimoe.FunGame.Testing.Tests.WebSocketTest();
|
_ = new Milimoe.FunGame.Testing.Tests.WebSocketTest();
|
||||||
|
|
||||||
CharacterModule cm = new();
|
CharacterModule cm = new();
|
||||||
|
@ -16,11 +16,11 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
Console.WriteLine(plugin + " is loaded.");
|
Console.WriteLine(plugin + " is loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, string> plugindllsha512 = [];
|
Dictionary<string, string> plugindllsha256 = [];
|
||||||
foreach (string pfp in PluginLoader.PluginFilePaths.Keys)
|
foreach (string pfp in PluginLoader.PluginFilePaths.Keys)
|
||||||
{
|
{
|
||||||
string text = Encryption.FileSha512(PluginLoader.PluginFilePaths[pfp]);
|
string text = Encryption.FileSha256(PluginLoader.PluginFilePaths[pfp]);
|
||||||
plugindllsha512.Add(pfp, text);
|
plugindllsha256.Add(pfp, text);
|
||||||
Console.WriteLine(pfp + $" is {text}.");
|
Console.WriteLine(pfp + $" is {text}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,20 +45,26 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, string> moduledllsha512 = [];
|
Dictionary<string, string> moduledllsha256 = [];
|
||||||
foreach (string mfp in GameModuleLoader.ModuleFilePaths.Keys)
|
foreach (string mfp in GameModuleLoader.ModuleFilePaths.Keys)
|
||||||
{
|
{
|
||||||
string text = Encryption.FileSha512(GameModuleLoader.ModuleFilePaths[mfp]);
|
string text = Encryption.FileSha256(GameModuleLoader.ModuleFilePaths[mfp]);
|
||||||
moduledllsha512.Add(mfp, text);
|
moduledllsha256.Add(mfp, text);
|
||||||
Console.WriteLine(mfp + $" is {text}.");
|
Console.WriteLine(mfp + $" is {text}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string moduledll in moduledllsha512.Keys)
|
GameModuleLoader serverModels = GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Server, []);
|
||||||
|
|
||||||
|
foreach (string moduledll in serverModels.ModuleServers.Keys)
|
||||||
{
|
{
|
||||||
string server = moduledllsha512[moduledll];
|
if (!serverModels.ModuleServers[moduledll].IsAnonymous)
|
||||||
if (plugindllsha512.TryGetValue(moduledll, out string? client) && client != "" && server == client)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine(moduledll + $" is checked pass.");
|
string server = Encryption.FileSha256(GameModuleLoader.ModuleFilePaths[moduledll]);
|
||||||
|
string client = moduledllsha256[moduledll];
|
||||||
|
if (server == client)
|
||||||
|
{
|
||||||
|
Console.WriteLine(moduledll + $" is checked pass.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,12 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
data.Add("sc", 1);
|
data.Add("sc", 1);
|
||||||
await HTTPClient.Send(SocketMessageType.AnonymousGameServer, OshimaGameModuleConstant.Anonymous, data);
|
await HTTPClient.Send(SocketMessageType.AnonymousGameServer, OshimaGameModuleConstant.Anonymous, data);
|
||||||
}
|
}
|
||||||
|
if (str == "sclist")
|
||||||
|
{
|
||||||
|
Dictionary<string, object> data = [];
|
||||||
|
data.Add("command", "sclist");
|
||||||
|
await HTTPClient.Send(SocketMessageType.AnonymousGameServer, OshimaGameModuleConstant.Anonymous, data);
|
||||||
|
}
|
||||||
if (str == "wsclose")
|
if (str == "wsclose")
|
||||||
{
|
{
|
||||||
await HTTPClient.Send(SocketMessageType.EndGame);
|
await HTTPClient.Send(SocketMessageType.EndGame);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user