diff --git a/MosswartMassacre/PluginCore.cs b/MosswartMassacre/PluginCore.cs index d58250a..bc11273 100644 --- a/MosswartMassacre/PluginCore.cs +++ b/MosswartMassacre/PluginCore.cs @@ -157,17 +157,22 @@ namespace MosswartMassacre { PluginSettings.Instance.VitalSharingEnabled = enabled; var tracker = _instance?._vitalSharingTracker; - if (tracker == null) return; - if (enabled) + if (tracker != null) { - tracker.Start(); - WriteToChat("[VitalShare] ENABLED"); - } - else - { - tracker.Stop(); - WriteToChat("[VitalShare] DISABLED"); + if (enabled) + { + tracker.Start(); + WriteToChat("[VitalShare] ENABLED"); + } + else + { + tracker.Stop(); + WriteToChat("[VitalShare] DISABLED"); + } } + // Sync the checkbox on the Settings tab so chat commands + // and the UI stay in lockstep. + Views.VVSTabbedMainView.RefreshSettingsFromConfig(); } catch (Exception ex) { diff --git a/MosswartMassacre/WebSocket.cs b/MosswartMassacre/WebSocket.cs index 058254b..db6b65b 100644 --- a/MosswartMassacre/WebSocket.cs +++ b/MosswartMassacre/WebSocket.cs @@ -112,6 +112,34 @@ namespace MosswartMassacre await SendEncodedAsync(regJson, _cts.Token); _logger?.Log("[WebSocket] REGISTERED"); + // ─── Re-subscribe to vital sharing on every (re)connect ─── + // The backend evicts subscribers on disconnect, so after a + // reconnect we need to re-announce or our share_* messages + // won't be forwarded to other clients. + try + { + if (PluginSettings.IsInitialized && PluginSettings.Instance.VitalSharingEnabled) + { + var tag = PluginSettings.Instance.CharTag; + var tags = string.IsNullOrWhiteSpace(tag) + ? new string[0] + : new[] { tag }; + var subEnvelope = new + { + type = "share_subscribe", + timestamp = DateTime.UtcNow.ToString("o"), + character_name = CoreManager.Current.CharacterFilter.Name, + tags = tags, + }; + await SendEncodedAsync(JsonConvert.SerializeObject(subEnvelope), _cts.Token); + _logger?.Log("[WebSocket] Vital sharing re-subscribed"); + } + } + catch (Exception ex) + { + _logger?.Log($"[WebSocket] Re-subscribe error: {ex.Message}"); + } + var buffer = new byte[4096]; // 2) Fire-and-forget receive loop diff --git a/MosswartMassacre/bin/Release/MosswartMassacre.dll b/MosswartMassacre/bin/Release/MosswartMassacre.dll index aaa74ff..bd9d490 100644 Binary files a/MosswartMassacre/bin/Release/MosswartMassacre.dll and b/MosswartMassacre/bin/Release/MosswartMassacre.dll differ