PalacePal/Pal.Client/Net/RemoteApi.cs

53 lines
1.6 KiB
C#
Raw Normal View History

2022-12-21 19:23:48 +00:00
using Dalamud.Logging;
using Grpc.Net.Client;
2022-11-24 22:28:31 +00:00
using Microsoft.Extensions.Logging;
using System;
2023-02-15 22:17:19 +00:00
using Dalamud.Game.Gui;
2023-02-15 01:38:04 +00:00
using Pal.Client.Configuration;
using Pal.Client.DependencyInjection;
2022-11-24 22:28:31 +00:00
namespace Pal.Client.Net
{
2023-02-15 22:17:19 +00:00
internal sealed partial class RemoteApi : IDisposable
{
#if DEBUG
public const string RemoteUrl = "http://localhost:5415";
#else
2023-02-22 23:02:31 +00:00
public const string RemoteUrl = "https://pal.liza.sh";
#endif
2023-02-15 22:17:19 +00:00
private readonly string _userAgent =
$"{typeof(RemoteApi).Assembly.GetName().Name?.Replace(" ", "")}/{typeof(RemoteApi).Assembly.GetName().Version?.ToString(2)}";
2022-10-30 19:39:12 +00:00
private readonly ILoggerFactory _loggerFactory;
private readonly ILogger<RemoteApi> _logger;
private readonly Chat _chat;
2023-02-15 22:17:19 +00:00
private readonly ConfigurationManager _configurationManager;
private readonly IPalacePalConfiguration _configuration;
2022-11-24 22:28:31 +00:00
2022-10-30 10:02:49 +00:00
private GrpcChannel? _channel;
2023-02-10 19:48:14 +00:00
private LoginInfo _loginInfo = new(null);
2023-02-11 20:10:45 +00:00
private bool _warnedAboutUpgrade;
public RemoteApi(
ILoggerFactory loggerFactory,
ILogger<RemoteApi> logger,
Chat chat,
ConfigurationManager configurationManager,
2023-02-15 22:17:19 +00:00
IPalacePalConfiguration configuration)
{
_loggerFactory = loggerFactory;
_logger = logger;
_chat = chat;
2023-02-15 22:17:19 +00:00
_configurationManager = configurationManager;
_configuration = configuration;
}
public void Dispose()
{
_logger.LogDebug("Disposing gRPC channel");
_channel?.Dispose();
_channel = null;
}
}
}