IWebSocketConnection.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. #nullable enable
  4. using System;
  5. using System.Net;
  6. using System.Net.WebSockets;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. using MediaBrowser.Model.Net;
  10. using Microsoft.AspNetCore.Http;
  11. namespace MediaBrowser.Controller.Net
  12. {
  13. public interface IWebSocketConnection
  14. {
  15. /// <summary>
  16. /// Occurs when [closed].
  17. /// </summary>
  18. event EventHandler<EventArgs>? Closed;
  19. /// <summary>
  20. /// Gets the last activity date.
  21. /// </summary>
  22. /// <value>The last activity date.</value>
  23. DateTime LastActivityDate { get; }
  24. /// <summary>
  25. /// Gets or sets the date of last Keeplive received.
  26. /// </summary>
  27. /// <value>The date of last Keeplive received.</value>
  28. DateTime LastKeepAliveDate { get; set; }
  29. /// <summary>
  30. /// Gets the query string.
  31. /// </summary>
  32. /// <value>The query string.</value>
  33. IQueryCollection QueryString { get; }
  34. /// <summary>
  35. /// Gets or sets the receive action.
  36. /// </summary>
  37. /// <value>The receive action.</value>
  38. Func<WebSocketMessageInfo, Task>? OnReceive { get; set; }
  39. /// <summary>
  40. /// Gets the state.
  41. /// </summary>
  42. /// <value>The state.</value>
  43. WebSocketState State { get; }
  44. /// <summary>
  45. /// Gets the remote end point.
  46. /// </summary>
  47. /// <value>The remote end point.</value>
  48. IPAddress? RemoteEndPoint { get; }
  49. /// <summary>
  50. /// Sends a message asynchronously.
  51. /// </summary>
  52. /// <typeparam name="T"></typeparam>
  53. /// <param name="message">The message.</param>
  54. /// <param name="cancellationToken">The cancellation token.</param>
  55. /// <returns>Task.</returns>
  56. /// <exception cref="ArgumentNullException">message</exception>
  57. Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
  58. Task ProcessAsync(CancellationToken cancellationToken = default);
  59. }
  60. }