-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved game server management through admin panel
- Loading branch information
Showing
13 changed files
with
590 additions
and
136 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/Dapr/AdminPanel.Host/DockerGameServerInstanceManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// <copyright file="ServerRestarter.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.AdminPanel.Host; | ||
|
||
using MUnique.OpenMU.Interfaces; | ||
|
||
/// <summary> | ||
/// An implementation of <see cref="IGameServerInstanceManager"/>. | ||
/// </summary> | ||
public class DockerGameServerInstanceManager : IGameServerInstanceManager | ||
{ | ||
private readonly IServerProvider _serverProvider; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DockerGameServerInstanceManager"/> class. | ||
/// </summary> | ||
/// <param name="serverProvider">The server provider.</param> | ||
public DockerGameServerInstanceManager(IServerProvider serverProvider) | ||
{ | ||
this._serverProvider = serverProvider; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public async ValueTask RestartAllAsync(bool onDatabaseInit) | ||
{ | ||
var gameServers = this._serverProvider.Servers.Where(server => server.Type == ServerType.GameServer).ToList(); | ||
foreach (var gameServer in gameServers) | ||
{ | ||
await gameServer.ShutdownAsync().ConfigureAwait(false); | ||
// It's started again automatically by the docker host. | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public async ValueTask InitializeGameServerAsync(byte serverId) | ||
{ | ||
// TODO: Implement this... by starting a new docker container | ||
|
||
} | ||
|
||
/// <inheritdoc /> | ||
public async ValueTask RemoveGameServerAsync(byte serverId) | ||
{ | ||
var gameServer = this._serverProvider.Servers | ||
.Where(server => server.Type == ServerType.GameServer) | ||
.FirstOrDefault(server => server.Id == serverId); | ||
if (gameServer is not null) | ||
{ | ||
await gameServer.ShutdownAsync().ConfigureAwait(false); | ||
// TODO: Remove the docker container | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// <copyright file="IGameServerInitializer.cs" company="MUnique"> | ||
Check warning on line 1 in src/Interfaces/IGameServerInstanceManager.cs GitHub Actions / build
|
||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.Interfaces; | ||
|
||
/// <summary> | ||
/// Interface for an instance which manages game servers. | ||
/// </summary> | ||
public interface IGameServerInstanceManager | ||
{ | ||
Check warning on line 11 in src/Interfaces/IGameServerInstanceManager.cs GitHub Actions / build
|
||
|
||
/// <summary> | ||
/// Restarts all servers of this container. | ||
/// </summary> | ||
/// <param name="onDatabaseInit">If set to <c>true</c>, this method is called during a database initialization.</param> | ||
/// <returns></returns> | ||
Check warning on line 17 in src/Interfaces/IGameServerInstanceManager.cs GitHub Actions / build
|
||
ValueTask RestartAllAsync(bool onDatabaseInit); | ||
|
||
/// <summary> | ||
/// Initializes a game server. | ||
/// </summary> | ||
/// <param name="serverId">The server identifier.</param> | ||
ValueTask InitializeGameServerAsync(byte serverId); | ||
|
||
/// <summary> | ||
/// Removes the game server instance. | ||
/// </summary> | ||
/// <param name="serverId">The server identifier.</param> | ||
ValueTask RemoveGameServerAsync(byte serverId); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
<div> | ||
<p><span>@Question</span></p> | ||
</div> | ||
|
||
<div class="float-right" role="toolbar" aria-label="buttons"> | ||
<div class="btn-group" role="group" aria-label="yes"> | ||
<button type="button" class="btn btn-primary" onclick=@(() => this.SetResponseAsync(true))>Yes</button> | ||
</div> | ||
<div class="btn-group" role="group" aria-label="no"> | ||
<button type="button" class="btn btn-secondary" onclick=@(() => this.SetResponseAsync(false))>No</button> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
|
||
@code { | ||
|
||
[CascadingParameter] | ||
BlazoredModalInstance BlazoredModal { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Gets or sets the text. | ||
/// </summary> | ||
[Parameter] | ||
public string Question { get; set; } = string.Empty; | ||
|
||
private async Task SetResponseAsync(bool yes) { | ||
await this.BlazoredModal.CloseAsync(ModalResult.Ok(yes)); | ||
} | ||
} |
Oops, something went wrong.