2
0

IWebSocketConnection.cs 2.1 KB

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