Skip to content

Commit

Permalink
Merge pull request #560 from CrosRoad95/improvments/MtaServerHostedSe…
Browse files Browse the repository at this point in the history
…rvice

Improve MtaServerHostedService
  • Loading branch information
CrosRoad95 authored Nov 3, 2024
2 parents 671db45 + d75891a commit 5fe7b3d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
10 changes: 0 additions & 10 deletions SlipeServer.Hosting/HostedMtaServer.cs

This file was deleted.

24 changes: 22 additions & 2 deletions SlipeServer.Hosting/MtaServerHostedService.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
namespace SlipeServer.Hosting;

public class MtaServerHostedService<T> : IHostedService where T : MtaServer
public class MtaServerHostedService<T> : IHostedLifecycleService where T : MtaServer
{
private readonly T server;

public MtaServerHostedService(T server)
{
this.server = server;

server.BuildFinalizer?.Invoke();
this.server.BuildFinalizer?.Invoke();
}

public Task StartAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}

public Task StartedAsync(CancellationToken cancellationToken)
{
this.server.Start();

return Task.CompletedTask;
}

public Task StartingAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}

public Task StoppedAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}

public Task StoppingAsync(CancellationToken cancellationToken)
{
this.server.Stop();

Expand Down

0 comments on commit 5fe7b3d

Please sign in to comment.