35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using CommonSocketLibrary.Abstract;
|
|
using CommonSocketLibrary.Common;
|
|
using Microsoft.Extensions.Logging;
|
|
using TwitchChatTTS.OBS.Socket.Data;
|
|
|
|
namespace TwitchChatTTS.OBS.Socket.Handlers
|
|
{
|
|
public class RequestResponseHandler : IWebSocketHandler
|
|
{
|
|
private ILogger Logger { get; }
|
|
public int OperationCode { get; set; } = 7;
|
|
|
|
public RequestResponseHandler(ILogger<RequestResponseHandler> logger) {
|
|
Logger = logger;
|
|
}
|
|
|
|
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data message)
|
|
{
|
|
if (message is not RequestResponseMessage obj || obj == null)
|
|
return;
|
|
|
|
switch (obj.RequestType) {
|
|
case "GetOutputStatus":
|
|
if (sender is not OBSSocketClient client)
|
|
return;
|
|
|
|
if (obj.RequestId == "stream") {
|
|
client.Live = obj.ResponseData["outputActive"].ToString() == "True";
|
|
Logger.LogWarning("Updated stream's live status to " + client.Live);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} |