using System;
using System.Threading;
using System.Threading.Tasks;
namespace RudderSdk.Core.Abstractions;
///
/// Low-level realtime (websocket) transport. There is no default implementation;
/// provide one through (Unity ships its own).
///
public interface IRealtimeTransport
{
/// Raised when the connection closes.
event Action Closed;
/// Raised for every incoming message.
event Action> Received;
/// Raised on transport errors.
event Action Error;
/// True while the connection is open.
bool IsConnected { get; }
/// Opens the connection, giving up after .
Task ConnectAsync(Uri uri, TimeSpan timeout, CancellationToken cancellationToken = default);
/// Sends one message.
Task SendAsync(ArraySegment data, CancellationToken cancellationToken = default);
/// Closes the connection.
Task CloseAsync(CancellationToken cancellationToken = default);
/// Pumps time-dependent logic; call every frame.
void Update(float deltaTime);
}