IWebSocket.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using MediaBrowser.Model.Net;
  2. using System;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. namespace MediaBrowser.Controller.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="endOfMessage">if set to <c>true</c> [end of message].</param>
  36. /// <param name="cancellationToken">The cancellation token.</param>
  37. /// <returns>Task.</returns>
  38. Task SendAsync(byte[] bytes, bool endOfMessage, CancellationToken cancellationToken);
  39. /// <summary>
  40. /// Sends the asynchronous.
  41. /// </summary>
  42. /// <param name="text">The text.</param>
  43. /// <param name="endOfMessage">if set to <c>true</c> [end of message].</param>
  44. /// <param name="cancellationToken">The cancellation token.</param>
  45. /// <returns>Task.</returns>
  46. Task SendAsync(string text, bool endOfMessage, CancellationToken cancellationToken);
  47. }
  48. }