Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Dapr/AdminPanel.Host/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using MUnique.OpenMU.AdminPanel.Host;
using MUnique.OpenMU.Dapr.Common;
using MUnique.OpenMU.Interfaces;
using MUnique.OpenMU.Persistence;
using MUnique.OpenMU.PlugIns;
using MUnique.OpenMU.ServerClients;
using MUnique.OpenMU.Persistence.EntityFramework.AdminAuth;
Expand All @@ -25,6 +26,7 @@
.AddSingleton<ILoginServer, LoginServer>()
.AddSingleton<IGameServerInstanceManager, DockerGameServerInstanceManager>()
.AddSingleton<IConnectServerInstanceManager, DockerConnectServerInstanceManager>()
.AddSingleton<IBackupService, BackupService>()
.AddAdminUserRepository();

builder.AddAdminPanel();
Expand Down
11 changes: 9 additions & 2 deletions src/Dapr/Common/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="Extensions.cs" company="MUnique">
// <copyright file="Extensions.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

Expand All @@ -14,7 +14,9 @@ namespace MUnique.OpenMU.Dapr.Common;
using MUnique.OpenMU.Interfaces;
using MUnique.OpenMU.Network;
using MUnique.OpenMU.Persistence;
using MUnique.OpenMU.Persistence.AdminAuth;
using MUnique.OpenMU.Persistence.EntityFramework;
using MUnique.OpenMU.Persistence.EntityFramework.AdminAuth;
using MUnique.OpenMU.PlugIns;
using Nito.AsyncEx.Synchronous;
using OpenTelemetry.Exporter;
Expand Down Expand Up @@ -53,7 +55,12 @@ public static IServiceCollection AddPeristenceProvider(this IServiceCollection s
.AddSingleton<IMigratableDatabaseContextProvider, PersistenceContextProvider>()
.AddSingleton(s => (PersistenceContextProvider)s.GetService<IMigratableDatabaseContextProvider>()!)
.AddSingleton(s => (IPersistenceContextProvider)s.GetService<IMigratableDatabaseContextProvider>()!)
.AddSingleton(s => new Lazy<IPersistenceContextProvider>(s.GetRequiredService<IPersistenceContextProvider>));
.AddSingleton(s => new Lazy<IPersistenceContextProvider>(s.GetRequiredService<IPersistenceContextProvider>))
.AddAdminUserRepository()
.AddSingleton<IBackupService>(s => new BackupService(
s.GetRequiredService<IPersistenceContextProvider>(),
s.GetRequiredService<IAdminUserRepository>()))
.AddSingleton<IDatabaseSnapshotService, DatabaseSnapshotService>();
}

/// <summary>
Expand Down
18 changes: 17 additions & 1 deletion src/GameServer/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace MUnique.OpenMU.GameServer;
/// <summary>
/// The game server to which game clients can connect.
/// </summary>
public sealed class GameServer : IGameServer, IDisposable, IGameServerContextProvider, IConnectionSource
public sealed class GameServer : IGameServer, IDisposable, IAsyncDisposable, IGameServerContextProvider, IConnectionSource
{
private readonly ILogger<GameServer> _logger;

Expand Down Expand Up @@ -458,6 +458,22 @@ public void Dispose()
(this._gameContext as IDisposable)?.Dispose();
}

/// <inheritdoc />
/// <remarks>
/// In contrast to <see cref="Dispose"/>, this also stops the periodic tasks of the game context.
/// </remarks>
public async ValueTask DisposeAsync()
{
if (this._gameContext is IAsyncDisposable asyncDisposable)
{
await asyncDisposable.DisposeAsync().ConfigureAwait(false);
}
else
{
this.Dispose();
}
}

private async ValueTask RemovePlayerFromGuildAsync(Player player, bool unregisterFromContext = true)
{
if (unregisterFromContext && player.GuildStatus?.GuildId is not null)
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/AdminAuth/AdminUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace MUnique.OpenMU.Persistence.AdminAuth;
/// Additionally, the admin panel must be usable before the game database has been initialized,
/// which wouldn't be possible if the credentials were stored in the game data schema.
/// </remarks>
public class AdminUser
public class AdminUser : IIdentifiable
{
/// <summary>
/// Gets or sets the identifier of this user.
Expand Down
23 changes: 23 additions & 0 deletions src/Persistence/BackupOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// <copyright file="BackupOptions.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.Persistence;

/// <summary>
/// Options which define what a backup contains.
/// </summary>
public sealed record BackupOptions
{
/// <summary>
/// Gets the default options, which include everything.
/// </summary>
public static BackupOptions Default { get; } = new();

/// <summary>
/// Gets a value indicating whether the accounts are included in the backup.
/// Exporting the accounts of a running server takes the most time, so it can be
/// skipped when only the configuration should be transferred.
/// </summary>
public bool IncludeAccounts { get; init; } = true;
}
Loading
Loading