2024-07-19 16:56:41 +00:00
|
|
|
using System.Net.WebSockets;
|
2024-03-12 18:05:27 +00:00
|
|
|
using CommonSocketLibrary.Abstract;
|
|
|
|
using CommonSocketLibrary.Common;
|
|
|
|
using TwitchChatTTS.Seven.Socket.Data;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Seven.Socket.Handlers
|
|
|
|
{
|
|
|
|
public class EndOfStreamHandler : IWebSocketHandler
|
|
|
|
{
|
2024-06-24 22:11:36 +00:00
|
|
|
public int OperationCode { get; } = 7;
|
2024-03-12 18:05:27 +00:00
|
|
|
|
2024-06-24 22:11:36 +00:00
|
|
|
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
2024-03-12 18:05:27 +00:00
|
|
|
{
|
2024-06-24 22:11:36 +00:00
|
|
|
if (data is not EndOfStreamMessage message || message == null)
|
2024-03-12 18:05:27 +00:00
|
|
|
return;
|
2024-06-17 00:19:31 +00:00
|
|
|
|
2024-06-24 22:11:36 +00:00
|
|
|
var code = message.Code - 4000;
|
2024-07-19 16:56:41 +00:00
|
|
|
await sender.DisconnectAsync(new SocketDisconnectionEventArgs(WebSocketCloseStatus.Empty.ToString(), code.ToString()));
|
2024-03-12 18:05:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|