mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-07 06:06:53 +00:00
feat: Completed early communication testing.
data-table has serious performance problem.
This commit is contained in:
@@ -30,7 +30,7 @@ WebApplication? RegisterAndConfigureServices()
|
||||
|
||||
insideApp.UseAuthorization();
|
||||
insideApp.MapControllers();
|
||||
insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
|
||||
// insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
|
||||
|
||||
return insideApp;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using SuperSocket.WebSocket.Server;
|
||||
using Newtonsoft.Json;
|
||||
using SuperSocket.WebSocket.Server;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer;
|
||||
|
||||
@@ -7,9 +8,65 @@ public class SuperSocketListener
|
||||
public async Task ListenAsync()
|
||||
{
|
||||
var host = WebSocketHostBuilder.Create()
|
||||
.UseWebSocketMessageHandler(async (session, message) => { await session.SendAsync(message.Message); })
|
||||
.UseWebSocketMessageHandler(async (session, message) =>
|
||||
{
|
||||
await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent<OutputEvent>
|
||||
{
|
||||
Action = "output",
|
||||
Type = ActionType.ResponseAction,
|
||||
Data = new OutputEvent()
|
||||
}));
|
||||
|
||||
for (int index = 0; index < 50; index++)
|
||||
{
|
||||
var data = new List<GetFileInfoEvent>();
|
||||
for (int j = 0; j < 500; j++)
|
||||
{
|
||||
data.Add(new GetFileInfoEvent
|
||||
{
|
||||
Name = j.ToString(),
|
||||
Size = j.ToString()
|
||||
});
|
||||
}
|
||||
|
||||
await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent<List<GetFileInfoEvent>>
|
||||
{
|
||||
Action = "getFileInfo",
|
||||
Type = ActionType.ResponseAction,
|
||||
Data = data
|
||||
}));
|
||||
}
|
||||
|
||||
await Task.Delay(100);
|
||||
})
|
||||
.Build();
|
||||
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public class CommunicateEvent<T> where T : class
|
||||
{
|
||||
[JsonProperty("action")] public string? Action { get; set; }
|
||||
|
||||
[JsonProperty("type")] public ActionType Type { get; set; }
|
||||
|
||||
[JsonProperty("data")] public T? Data { get; set; }
|
||||
}
|
||||
|
||||
public class OutputEvent
|
||||
{
|
||||
[JsonProperty("text")] public string Text => DateTime.Now.ToString("HH:mm:ss");
|
||||
}
|
||||
|
||||
public class GetFileInfoEvent
|
||||
{
|
||||
[JsonProperty("name")] public string Name { get; set; }
|
||||
[JsonProperty("size")] public string Size { get; set; }
|
||||
}
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
RequestAction,
|
||||
ResponseAction
|
||||
}
|
@@ -25,6 +25,10 @@
|
||||
<EmbeddedResource Include="UiStaticResources\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <ProjectReference Include="..\ZonyLrcTools.Cli\ZonyLrcTools.Cli.csproj" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
Reference in New Issue
Block a user