Skip to content

Commit

Permalink
Add fix for WebSocket bypass failing if plugin loaded before player l…
Browse files Browse the repository at this point in the history
…ogin
  • Loading branch information
joshua-software-dev committed Jul 14, 2023
1 parent 939beee commit 0198494
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
15 changes: 15 additions & 0 deletions LMeter/src/Cactbot/IinactCactbotClient.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Dalamud.Game.ClientState;
using Dalamud.Logging;
using Dalamud.Plugin;
using Dalamud.Plugin.Ipc;
Expand All @@ -19,6 +20,7 @@ namespace LMeter.Cactbot;
public class IinactCactbotClient : IActClient
{
private readonly bool _bypassWebSocket;
private readonly ClientState _clientState;
private readonly CancellationTokenSource _cancelTokenSource;
private readonly DalamudPluginInterface _dpi;
private readonly HttpClient _httpClient;
Expand Down Expand Up @@ -66,19 +68,23 @@ public List<ActEvent> PastEvents
public IinactCactbotClient
(
bool bypassWebSocket,
ClientState clientState,
CancellationTokenSource cts,
DalamudPluginInterface dpi,
HttpClient httpClient,
string totallyNotCefUrl
)
{
_bypassWebSocket = bypassWebSocket;
_clientState = clientState;
_cancelTokenSource = cts;
_dpi = dpi;
_httpClient = httpClient;
_status = SubscriptionStatus.NotConnected;
_totallyNotCefUrl = totallyNotCefUrl;

_clientState.Login += HandleOnLogin;

try
{
subscriptionReceiver = _dpi.GetIpcProvider<JObject, bool>(LMeterCactbotSubscriptionIpcEndpoint);
Expand All @@ -87,6 +93,14 @@ string totallyNotCefUrl
catch { }
}

private void HandleOnLogin(object? sender, EventArgs args)
{
if (_bypassWebSocket && !_fakeHandshakeComplete)
{
RetryConnection();
}
}

private void SendHttpPostRequest(string message)
{
_httpClient
Expand Down Expand Up @@ -326,6 +340,7 @@ public void RetryConnection()
public void Dispose()
{
_fakeHandshakeComplete = false;
_clientState.Login -= HandleOnLogin;
subscriptionReceiver?.UnregisterFunc();
this.Dispose(true);
GC.SuppressFinalize(this);
Expand Down
1 change: 1 addition & 0 deletions LMeter/src/Cactbot/TotallyNotCefCactbotHttpSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ bool enableAudio
_iinactCactbotClient = new
(
_bypassWebSocket,
PluginManager.Instance?.ClientState ?? throw new NullReferenceException(),
_cancelTokenSource,
PluginManager.Instance?.PluginInterface ?? throw new NullReferenceException(),
_httpClient,
Expand Down
2 changes: 1 addition & 1 deletion Version/Version.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<PluginVersion>0.2.0.14</PluginVersion>
<PluginVersion>0.2.0.15</PluginVersion>
</PropertyGroup>
</Project>
4 changes: 4 additions & 0 deletions deps/txt/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.2.0.15
- Add fix for Cactbot WebSocket bypass option potentially not starting
correctly if the plugin loaded before the player had finished logging in.

# Version 0.2.0.14
- Fix Cactbot URL potentially causing crashes on plugin load if the url was not
valid.
Expand Down
12 changes: 6 additions & 6 deletions repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"Name": "LMeter",
"Description": "Plugin to display ACT combat log data. Now with Cactbot integration!",
"InternalName": "LMeter",
"AssemblyVersion": "0.2.0.14",
"TestingAssemblyVersion": "0.2.0.14",
"AssemblyVersion": "0.2.0.15",
"TestingAssemblyVersion": "0.2.0.15",
"RepoUrl": "https://github.com/joshua-software-dev/LMeter",
"ApplicableVersion": "any",
"DalamudApiLevel": 8,
Expand All @@ -35,10 +35,10 @@
"DownloadCount": 0,
"LastUpdate": 0,
"LoadPriority": 69420,
"DownloadLinkInstall": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.14/latest.zip",
"DownloadLinkTesting": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.14/latest.zip",
"DownloadLinkUpdate": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.14/latest.zip",
"DownloadLinkInstall": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.15/latest.zip",
"DownloadLinkTesting": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.15/latest.zip",
"DownloadLinkUpdate": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.15/latest.zip",
"IconUrl": "https://raw.githubusercontent.com/joshua-software-dev/LMeter/master/deps/img/icon.png",
"Changelog": "# Version 0.2.0.14\n- Fix Cactbot URL potentially causing crashes on plugin load if the url was not\n valid."
"Changelog": "# Version 0.2.0.15\n- Add fix for Cactbot WebSocket bypass option potentially not starting\n correctly if the plugin loaded before the player had finished logging in."
}
]

0 comments on commit 0198494

Please sign in to comment.