2022-12-21 19:23:48 +00:00
|
|
|
|
using Dalamud.Logging;
|
2022-10-23 02:38:58 +00:00
|
|
|
|
using Grpc.Net.Client;
|
2022-11-24 22:28:31 +00:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2022-10-23 02:38:58 +00:00
|
|
|
|
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;
|
2022-10-23 02:38:58 +00:00
|
|
|
|
|
2022-11-24 22:28:31 +00:00
|
|
|
|
namespace Pal.Client.Net
|
2022-10-23 02:38:58 +00:00
|
|
|
|
{
|
2023-02-15 22:17:19 +00:00
|
|
|
|
internal sealed partial class RemoteApi : IDisposable
|
2022-10-23 02:38:58 +00:00
|
|
|
|
{
|
|
|
|
|
#if DEBUG
|
2023-02-15 01:38:04 +00:00
|
|
|
|
public const string RemoteUrl = "http://localhost:5145";
|
2022-10-23 02:38:58 +00:00
|
|
|
|
#else
|
2023-02-15 09:20:25 +00:00
|
|
|
|
public const string RemoteUrl = "https://pal.liza.sh";
|
2022-10-23 02:38:58 +00:00
|
|
|
|
#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
|
|
|
|
|
2023-02-15 22:17:19 +00:00
|
|
|
|
private readonly ILoggerFactory _grpcToPluginLogLoggerFactory = LoggerFactory.Create(builder =>
|
|
|
|
|
builder.AddProvider(new GrpcLoggerProvider()).AddFilter("Grpc", LogLevel.Trace));
|
|
|
|
|
|
|
|
|
|
private readonly ChatGui _chatGui;
|
|
|
|
|
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;
|
2022-10-23 02:38:58 +00:00
|
|
|
|
|
2023-02-15 22:17:19 +00:00
|
|
|
|
public RemoteApi(ChatGui chatGui, ConfigurationManager configurationManager,
|
|
|
|
|
IPalacePalConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
_chatGui = chatGui;
|
|
|
|
|
_configurationManager = configurationManager;
|
|
|
|
|
_configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-23 02:38:58 +00:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2022-11-24 06:24:45 +00:00
|
|
|
|
PluginLog.Debug("Disposing gRPC channel");
|
2022-10-23 02:38:58 +00:00
|
|
|
|
_channel?.Dispose();
|
|
|
|
|
_channel = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|