2
0

IClientWebSocket.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.Model.ApiClient
  6. {
  7. /// <summary>
  8. /// Interface IClientWebSocket
  9. /// </summary>
  10. public interface IClientWebSocket : IDisposable
  11. {
  12. /// <summary>
  13. /// Occurs when [closed].
  14. /// </summary>
  15. event EventHandler Closed;
  16. /// <summary>
  17. /// Gets or sets the state.
  18. /// </summary>
  19. /// <value>The state.</value>
  20. WebSocketState State { get; }
  21. /// <summary>
  22. /// Connects the async.
  23. /// </summary>
  24. /// <param name="url">The URL.</param>
  25. /// <param name="cancellationToken">The cancellation token.</param>
  26. /// <returns>Task.</returns>
  27. Task ConnectAsync(string url, CancellationToken cancellationToken);
  28. /// <summary>
  29. /// Gets or sets the receive action.
  30. /// </summary>
  31. /// <value>The receive action.</value>
  32. Action<byte[]> OnReceiveBytes { get; set; }
  33. /// <summary>
  34. /// Gets or sets the on receive.
  35. /// </summary>
  36. /// <value>The on receive.</value>
  37. Action<string> OnReceive { get; set; }
  38. /// <summary>
  39. /// Sends the async.
  40. /// </summary>
  41. /// <param name="bytes">The bytes.</param>
  42. /// <param name="type">The type.</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(byte[] bytes, WebSocketMessageType type, bool endOfMessage, CancellationToken cancellationToken);
  47. }
  48. }