PalacePal/Pal.Client/Net/RemoteApi.cs

52 lines
1.5 KiB
C#
Raw Normal View History

2023-03-26 13:47:18 +00:00
using System;
using Dalamud.Game.Gui;
using Dalamud.Logging;
using Grpc.Net.Client;
2022-11-24 22:28:31 +00:00
using Microsoft.Extensions.Logging;
2023-02-15 01:38:04 +00:00
using Pal.Client.Configuration;
using Pal.Client.DependencyInjection;
2023-03-30 20:01:43 +00:00
namespace Pal.Client.Net;
internal sealed partial class RemoteApi : IDisposable
{
#if DEBUG
2023-03-30 20:01:43 +00:00
public const string RemoteUrl = "http://localhost:5415";
#else
2023-07-30 20:32:04 +00:00
public const string RemoteUrl = "https://connect.palacepal.com";
#endif
2023-03-30 20:01:43 +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
2023-03-30 20:01:43 +00:00
private readonly ILoggerFactory _loggerFactory;
private readonly ILogger<RemoteApi> _logger;
private readonly Chat _chat;
private readonly ConfigurationManager _configurationManager;
private readonly IPalacePalConfiguration _configuration;
2022-11-24 22:28:31 +00:00
2023-03-30 20:01:43 +00:00
private GrpcChannel? _channel;
private LoginInfo _loginInfo = new(null);
private bool _warnedAboutUpgrade;
2023-03-30 20:01:43 +00:00
public RemoteApi(
ILoggerFactory loggerFactory,
ILogger<RemoteApi> logger,
Chat chat,
ConfigurationManager configurationManager,
IPalacePalConfiguration configuration)
{
_loggerFactory = loggerFactory;
_logger = logger;
_chat = chat;
_configurationManager = configurationManager;
_configuration = configuration;
}
2023-02-15 22:17:19 +00:00
2023-03-30 20:01:43 +00:00
public void Dispose()
{
_logger.LogDebug("Disposing gRPC channel");
_channel?.Dispose();
_channel = null;
}
}