IWebSocket.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using MediaBrowser.Model.Net;
  2. using System;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. namespace MediaBrowser.Common.Net
  6. {
  7. /// <summary>
  8. /// Interface IWebSocket
  9. /// </summary>
  10. public interface IWebSocket : IDisposable
  11. {
  12. /// <summary>
  13. /// Occurs when [closed].
  14. /// </summary>
  15. event EventHandler<EventArgs> Closed;
  16. /// <summary>
  17. /// Gets or sets the state.
  18. /// </summary>
  19. /// <value>The state.</value>
  20. WebSocketState State { get; }
  21. /// <summary>
  22. /// Gets or sets the receive action.
  23. /// </summary>
  24. /// <value>The receive action.</value>
  25. Action<byte[]> OnReceiveBytes { get; set; }
  26. /// <summary>
  27. /// Gets or sets the on receive.
  28. /// </summary>
  29. /// <value>The on receive.</value>
  30. Action<string> OnReceive { get; set; }
  31. /// <summary>
  32. /// Sends the async.
  33. /// </summary>
  34. /// <param name="bytes">The bytes.</param>
  35. /// <param name="type">The type.</param>
  36. /// <param name="endOfMessage">if set to <c>true</c> [end of message].</param>
  37. /// <param name="cancellationToken">The cancellation token.</param>
  38. /// <returns>Task.</returns>
  39. Task SendAsync(byte[] bytes, WebSocketMessageType type, bool endOfMessage, CancellationToken cancellationToken);
  40. }
  41. }