using System; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Net; namespace MediaBrowser.Common.Net { public interface IWebSocketConnection : IDisposable { /// /// Gets or sets the receive action. /// /// The receive action. Action OnReceive { get; set; } /// /// Gets the state. /// /// The state. WebSocketState State { get; } /// /// Gets the remote end point. /// /// The remote end point. string RemoteEndPoint { get; } /// /// Sends a message asynchronously. /// /// /// The message. /// The cancellation token. /// Task. /// message Task SendAsync(WebSocketMessage message, CancellationToken cancellationToken); /// /// Sends a message asynchronously. /// /// The buffer. /// The cancellation token. /// Task. Task SendAsync(byte[] buffer, CancellationToken cancellationToken); /// /// Sends a message asynchronously. /// /// The buffer. /// The type. /// The cancellation token. /// Task. /// buffer Task SendAsync(byte[] buffer, WebSocketMessageType type, CancellationToken cancellationToken); } /// /// Class WebSocketMessage /// /// public class WebSocketMessage { /// /// Gets or sets the type of the message. /// /// The type of the message. public string MessageType { get; set; } /// /// Gets or sets the data. /// /// The data. public T Data { get; set; } } /// /// Class WebSocketMessageInfo /// public class WebSocketMessageInfo : WebSocketMessage { /// /// Gets or sets the connection. /// /// The connection. public IWebSocketConnection Connection { get; set; } } }