using System;
using System.Threading;
using System.Threading.Tasks;

namespace RudderSdk.Unity
{
    /// <summary>
    /// Interface for WebSocket transport adapters used by the realtime transport bridge.
    /// Provides connect, send, close, and main-thread event dispatch for WebSocket connections.
    /// </summary>
    public interface IWebSocketAdapter
    {
        event Action Closed;
        event Action<ArraySegment<byte>> Received;
        event Action<Exception> ReceivedError;
        bool IsConnected { get; }
        bool IsConnecting { get; }
        Task ConnectAsync(Uri uri, int timeoutSeconds, CancellationToken cancellationToken = default);
        Task CloseAsync();
        Task SendAsync(ArraySegment<byte> data, CancellationToken cancellationToken = default);
    }
}
