Skip to content

Commit

Permalink
Convert to non-generic type
Browse files Browse the repository at this point in the history
  • Loading branch information
ArachisH committed Mar 22, 2024
1 parent 90f34e6 commit 06913be
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Tanji.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ static void CleanUp(PosixSignalContext context)

private readonly ILogger<Program> _logger;
private readonly IWebInterceptionService _webInterception;
private readonly IClientHandlerService<CachedGame> _clientHandler;
private readonly IClientHandlerService _clientHandler;
private readonly IConnectionHandlerService<PacketMiddlemanService> _connectionHandler;

public Program(ILogger<Program> logger,
IWebInterceptionService webInterception,
IClientHandlerService<CachedGame> clientHandler,
IClientHandlerService clientHandler,
IConnectionHandlerService<PacketMiddlemanService> connectionHandler)
{
_logger = logger;
Expand All @@ -70,7 +70,7 @@ public async Task RunAsync(CancellationToken cancellationToken = default)
string ticket = await _webInterception.InterceptTicketAsync(cancellationToken).ConfigureAwait(false);
_logger.LogInformation("Game Ticket: {Ticket}", ticket);

CachedGame game = _clientHandler.PatchClient(HPlatform.Flash, null);
IGame game = _clientHandler.PatchClient(HPlatform.Flash);
_logger.LogInformation("Client Processed : {game.path}", game.Path);

var connectionContext = new HConnectionContext(game);
Expand Down
3 changes: 1 addition & 2 deletions Tanji.Core/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Tanji.Core.Services;
using Tanji.Core.ViewModels;
using Tanji.Core.Habbo.Canvas;
using Tanji.Core.Configuration;

using Microsoft.Extensions.Options;
Expand All @@ -18,7 +17,7 @@ public static IServiceCollection AddTanjiCore(this IServiceCollection services)

// Services
services.AddSingleton<IWebInterceptionService, WebInterceptionService>();
services.AddSingleton<IClientHandlerService<CachedGame>, ClientHandlerService>();
services.AddSingleton<IClientHandlerService, ClientHandlerService>();

services.AddSingleton<PacketMiddlemanService>();
services.AddSingleton<IConnectionHandlerService<PacketMiddlemanService>, ConnectionHandlerService>();
Expand Down
4 changes: 2 additions & 2 deletions Tanji.Core/Services/IClientHandlerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace Tanji.Core.Services;

public interface IClientHandlerService<TGame> where TGame : IGame
public interface IClientHandlerService
{
DirectoryInfo PatchedClientsDirectory { get; }

public TGame PatchClient(HPlatform platform, string? clientPath = null);
IGame PatchClient(HPlatform platform, string? clientPath = null);
public Process? LaunchClient(HPlatform platform, string ticket, string? clientPath = null);
bool TryGetIdentifiers(string? revision, out Outgoing? outgoing, out Incoming? incoming);
}
4 changes: 2 additions & 2 deletions Tanji.Core/Services/Implementations/ClientHandlerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace Tanji.Core.Services;

public sealed class ClientHandlerService(ILogger<ClientHandlerService> logger, IOptions<TanjiOptions> options) : IClientHandlerService<CachedGame>
public sealed class ClientHandlerService(ILogger<ClientHandlerService> logger, IOptions<TanjiOptions> options) : IClientHandlerService
{
private static readonly JsonSerializerOptions SerializerOptions;

Expand All @@ -44,7 +44,7 @@ static ClientHandlerService()
SerializerOptions.Converters.Add(new IPEndPointConverter());
}

public CachedGame PatchClient(HPlatform platform, string? clientPath = null)
public IGame PatchClient(HPlatform platform, string? clientPath = null)
{
if (string.IsNullOrWhiteSpace(clientPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public sealed class ConnectionHandlerService : IConnectionHandlerService<PacketM
{
private readonly PacketMiddlemanService _packetMiddleman;
private readonly ILogger<ConnectionHandlerService> _logger;
private readonly IClientHandlerService<CachedGame> _clientHandler;
private readonly IClientHandlerService _clientHandler;

public ObservableCollection<HConnection<PacketMiddlemanService>> Connections { get; } = [];

public ConnectionHandlerService(ILogger<ConnectionHandlerService> logger,
IClientHandlerService<CachedGame> clientHandler,
IClientHandlerService clientHandler)
PacketMiddlemanService packetMiddleman)
{
_logger = logger;
Expand Down

0 comments on commit 06913be

Please sign in to comment.