Changed command dictionary to a command tree. Fixed various requests. OBS reconnection added if identified previously.

This commit is contained in:
Tom
2024-07-19 16:56:41 +00:00
parent e6b3819356
commit 472bfcee5d
56 changed files with 1943 additions and 1553 deletions

View File

@@ -2,19 +2,16 @@ using CommonSocketLibrary.Abstract;
using CommonSocketLibrary.Common;
using Serilog;
using TwitchChatTTS.OBS.Socket.Data;
using TwitchChatTTS.OBS.Socket.Manager;
namespace TwitchChatTTS.OBS.Socket.Handlers
{
public class IdentifiedHandler : IWebSocketHandler
{
private readonly OBSManager _manager;
private readonly ILogger _logger;
public int OperationCode { get; } = 2;
public IdentifiedHandler(OBSManager manager, ILogger logger)
public IdentifiedHandler(ILogger logger)
{
_manager = manager;
_logger = logger;
}
@@ -22,20 +19,22 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
{
if (data is not IdentifiedMessage message || message == null)
return;
if (sender is not OBSSocketClient obs)
return;
_manager.Connected = true;
obs.Identified = true;
_logger.Information("Connected to OBS via rpc version " + message.NegotiatedRpcVersion + ".");
try
{
await _manager.GetGroupList(async groups => await _manager.GetGroupSceneItemList(groups));
await obs.GetGroupList(async groups => await obs.GetGroupSceneItemList(groups));
}
catch (Exception e)
{
_logger.Error(e, "Failed to load OBS group info upon OBS identification.");
}
await _manager.UpdateStreamingState();
await obs.UpdateStreamingState();
}
}
}