You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
849 B

using CoreAgent.WebSocketTransport.Models;
namespace CoreAgent.WebSocketTransport.Interfaces;
/// <summary>
/// WebSocket 传输接口
/// 单一职责:连接管理
/// </summary>
public interface IWebSocketTransport : IDisposable
{
/// <summary>
/// 获取连接状态
/// </summary>
bool IsConnected { get; }
/// <summary>
/// 获取最后心跳时间
/// </summary>
DateTime? LastHeartbeat { get; }
/// <summary>
/// 异步连接 WebSocket 服务器
/// </summary>
/// <param name="cancellationToken">取消令牌</param>
Task ConnectAsync(CancellationToken cancellationToken = default);
/// <summary>
/// 异步关闭连接
/// </summary>
/// <param name="cancellationToken">取消令牌</param>
Task CloseAsync(CancellationToken cancellationToken = default);
}