continuity/Continuity.AuthServer/Services/WonderkingAuthServer.cs

83 lines
2.1 KiB
C#
Raw Normal View History

2023-11-21 20:37:50 +00:00
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
2023-11-20 18:58:30 +00:00
using System.Net;
2023-08-09 14:23:41 +00:00
using System.Net.Sockets;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NetCoreServer;
namespace Continuity.AuthServer.Services;
2023-11-19 16:07:28 +00:00
2023-08-09 14:23:41 +00:00
public class WonderkingAuthServer : TcpServer, IHostedService
{
chore: .net8 support and extended support for pipeline jobs fix: incorrect command fix: incorrect command fix: incorrect command fix: export tools path chore: test dir fix: test build script fix: missing semicolon fix: missing semicolon fix: missing buildscript fix: missing buildscript chore: update build to .net7 ci: set root dir ci: set root dir revert: .net 8 support for benchmarks ci: disable docker for ci ci: disable docker for ci ci: disable docker for ci ci: trigger ci: i stg ci: let's hope its the correct one ci: i stg ci: further sonarscanner setup ci: add tools ci: rearrange ci: verbose output ci: hardcoded project key ci: test env ci: test more env ci: env test again ci: test env ci: shit ci: final setup ci: final setup ci: final setup ci: adjust buildscript ci: nuke ci: install java ci: install java refactor: loggermessages to own namespace chore: switch to dotnet foundation editorconfig preset ci: switch to basic gitea ci ci: steps ci: add missing runs-on ci: remove unnecessary actions ci: test attempt? ci: add missing name for step ci: fix missing project name reference ci: lets try again ci: again ci: again.. ci: idk at this point ci: append path prematurely ci: add path to bash cli: I really don't know ci: again.... ci: idk ci: again.... ci: another one ci: fix incorrect path add-path ci: add dependency track support ci: fix upload ci: forgot to adjust data for action ci: incorrect path? ci: add version tag ci: idk ci: fix incorrect path for bom ci: fix version tag ci: disable github license resolution for now ci: does this work ci: another one bites the dust chore: .net 8 and extended pipeline support ci: again chore: dockerignore added chore(deps): update dependency benchmarkdotnet to v0.13.10 Signed-off-by: noreply@rainote.dev ci: dependency track can run on any branch ci: first attempt docker image ci: again ci: some fixes ci: idk ci: does this help ci: idk ci: another one ci: forgot ci: downgrade qemu setup ci: downgrade.. ci: v1 includes docker ci: rearrange ci: idk what to do with this ci: let's try cat ci: alt ci: depressing ci: yikes ci: ah come on ci: let's try new version again ci: again ci: another one ci: another one ci: confusion ci: try single ci: aaaa ci: one more time ci: again main (#69) Reviewed-on: https://forge.rainote.dev/wonderking/continuity/pulls/69 Co-authored-by: Timothy Schenk <admin@rainote.dev> Co-committed-by: Timothy Schenk <admin@rainote.dev> chore: ci jobs expanded & .net 8 support ci: branch name sanitization for docker ci: another attempt ci: forgot actor chore: remove nuke remnants chore(deps): update dependency dotnet-sdk to v7.0.403 Signed-off-by: noreply@rainote.dev refactor: shared data into library refactor: rewrite for packethandler/id map chore: logging chore: Sonar Warnings chore: upgrade to .net8 image chore: fetch all required information for characters chore: upgrade to .net 8 ci: install .net 7.0 alongside 8.0 for sbom fix: incorrect job ci: let's try arm64 again ci: adjust project for .net 8 support chore: adjustments to composefile chore: analyzer setup chore: analyzer and project settings updated chore: ci jobs expanded & .net 8 support
2023-10-27 17:47:17 +00:00
private readonly ILogger<WonderkingAuthServer> _logger;
private readonly IServiceProvider _serviceProvider;
2023-08-09 14:23:41 +00:00
public WonderkingAuthServer(IPAddress address, int port, ILogger<WonderkingAuthServer> logger,
2023-08-10 08:47:35 +00:00
IServiceProvider serviceProvider) : base(address, port)
2023-08-09 14:23:41 +00:00
{
2023-11-19 16:07:28 +00:00
_logger = logger;
_serviceProvider = serviceProvider;
}
public Task StartAsync(CancellationToken cancellationToken)
{
2023-11-19 16:07:28 +00:00
Start();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
2023-11-19 16:07:28 +00:00
DisconnectAll();
Stop();
return Task.CompletedTask;
2023-08-09 14:23:41 +00:00
}
2023-11-19 16:07:28 +00:00
protected override TcpSession CreateSession()
{
return ActivatorUtilities.CreateInstance<AuthSession>(_serviceProvider, this);
}
2023-08-09 14:23:41 +00:00
protected override void OnStarting()
{
2023-11-19 16:07:28 +00:00
_logger.LogInformation("Starting");
2023-08-09 14:23:41 +00:00
base.OnStarting();
}
protected override void OnStarted()
{
2023-11-19 16:07:28 +00:00
_logger.LogInformation("Started");
2023-08-09 14:23:41 +00:00
base.OnStarted();
}
protected override void OnStopping()
{
2023-11-19 16:07:28 +00:00
_logger.LogInformation("Stopping");
2023-08-09 14:23:41 +00:00
base.OnStopping();
}
protected override void OnStopped()
{
2023-11-19 16:07:28 +00:00
_logger.LogInformation("Stopped");
2023-08-09 14:23:41 +00:00
base.OnStopped();
}
2023-11-16 22:51:30 +00:00
protected override void OnConnected(TcpSession session)
{
2023-11-19 16:07:28 +00:00
_logger.LogInformation("Client connected {Session}", session.Id);
2023-11-16 22:51:30 +00:00
base.OnConnected(session);
}
protected override void OnDisconnected(TcpSession session)
{
2023-11-19 16:07:28 +00:00
_logger.LogInformation("Client disconnected {Session}", session.Id);
2023-11-16 22:51:30 +00:00
base.OnDisconnected(session);
}
2023-11-19 16:07:28 +00:00
protected override void OnError(SocketError error)
{
_logger.LogError("An error has occured {Error}", error);
}
2023-08-11 09:31:30 +00:00
}