2024-03-12 14:05:27 -04:00
|
|
|
using CommonSocketLibrary.Abstract;
|
|
|
|
using CommonSocketLibrary.Common;
|
2024-06-16 20:19:31 -04:00
|
|
|
using Serilog;
|
2024-03-12 14:05:27 -04:00
|
|
|
using TwitchChatTTS.OBS.Socket.Data;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.OBS.Socket.Handlers
|
|
|
|
{
|
|
|
|
public class RequestResponseHandler : IWebSocketHandler
|
|
|
|
{
|
|
|
|
private ILogger Logger { get; }
|
|
|
|
public int OperationCode { get; set; } = 7;
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
public RequestResponseHandler(ILogger logger)
|
|
|
|
{
|
2024-03-12 14:05:27 -04:00
|
|
|
Logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data message)
|
|
|
|
{
|
|
|
|
if (message is not RequestResponseMessage obj || obj == null)
|
|
|
|
return;
|
2024-06-16 20:19:31 -04:00
|
|
|
|
|
|
|
switch (obj.RequestType)
|
|
|
|
{
|
2024-03-12 14:05:27 -04:00
|
|
|
case "GetOutputStatus":
|
|
|
|
if (sender is not OBSSocketClient client)
|
|
|
|
return;
|
2024-06-16 20:19:31 -04:00
|
|
|
|
|
|
|
if (obj.RequestId == "stream")
|
|
|
|
{
|
2024-03-15 08:27:35 -04:00
|
|
|
client.Live = obj.ResponseData["outputActive"].ToString() == "True";
|
2024-06-16 20:19:31 -04:00
|
|
|
Logger.Warning("Updated stream's live status to " + client.Live);
|
2024-03-12 14:05:27 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|