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.Seven.Socket.Data;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Seven.Socket.Handlers
|
|
|
|
{
|
|
|
|
public class ReconnectHandler : IWebSocketHandler
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
private readonly ILogger _logger;
|
|
|
|
public int OperationCode { get; } = 4;
|
2024-03-12 14:05:27 -04:00
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
public ReconnectHandler(ILogger logger)
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
_logger = logger;
|
2024-03-12 14:05:27 -04:00
|
|
|
}
|
|
|
|
|
2024-08-11 17:41:22 -04:00
|
|
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
2024-03-12 14:05:27 -04:00
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
if (data is not ReconnectMessage message || message == null)
|
2024-08-11 17:41:22 -04:00
|
|
|
return Task.CompletedTask;
|
2024-03-12 14:05:27 -04:00
|
|
|
|
2024-08-11 17:41:22 -04:00
|
|
|
_logger.Information($"7tv server wants this client to reconnect [reason: {message.Reason}]");
|
|
|
|
return Task.CompletedTask;
|
2024-03-12 14:05:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|