mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 20:23:22 +00:00
Added WebSocket listener service.
This commit is contained in:
parent
cde1d32d33
commit
dbc1e44d2a
@ -36,7 +36,7 @@ globalOption:
|
||||
plugin:
|
||||
- name: NetEase # 基于网易云音乐的歌词下载器。
|
||||
priority: 1 # 优先级,升序排列,改为 -1 时禁用。
|
||||
depth: 30 # 搜索深度,值越大搜索结果越多,但搜索时间越长。
|
||||
depth: 10 # 搜索深度,值越大搜索结果越多,但搜索时间越长。
|
||||
- name: QQ # 基于 QQ 音乐的歌词下载器。
|
||||
priority: 2
|
||||
# depth: 10 # 暂时不支持。
|
||||
|
@ -1,25 +1,36 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
using ZonyLrcTools.LocalServer;
|
||||
|
||||
var app = RegisterAndConfigureServices();
|
||||
await ListenServices();
|
||||
|
||||
async Task ListenServices()
|
||||
{
|
||||
await new SuperSocketListener().ListenAsync();
|
||||
await app?.RunAsync()!;
|
||||
}
|
||||
|
||||
WebApplication? RegisterAndConfigureServices()
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
@ -1,28 +1,12 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:49856",
|
||||
"sslPort": 44367
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"ZonyLrcTools.LocalServer": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7015;http://localhost:5265",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:50002",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
15
src/ZonyLrcTools.LocalServer/SuperSocketListener.cs
Normal file
15
src/ZonyLrcTools.LocalServer/SuperSocketListener.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using SuperSocket.WebSocket.Server;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer;
|
||||
|
||||
public class SuperSocketListener
|
||||
{
|
||||
public async Task ListenAsync()
|
||||
{
|
||||
var host = WebSocketHostBuilder.Create()
|
||||
.UseWebSocketMessageHandler(async (session, message) => { await session.SendAsync(message.Message); })
|
||||
.Build();
|
||||
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
@ -7,6 +7,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="SuperSocket.WebSocket" Version="2.0.0-beta.11" />
|
||||
<PackageReference Include="SuperSocket.WebSocket.Server" Version="2.0.0-beta.11" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -14,4 +19,8 @@
|
||||
<Folder Include="Controllers" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZonyLrcTools.Cli\ZonyLrcTools.Cli.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Default": "Debug",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,14 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"serverOptions": {
|
||||
"name": "ZonyLRcToolsServer",
|
||||
"listeners": [
|
||||
{
|
||||
"ip": "Any",
|
||||
"port": 50001
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user