2
0

IWebSocketConnection.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Net.WebSockets;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Model.Net;
  6. using MediaBrowser.Model.Services;
  7. using Microsoft.AspNetCore.Http;
  8. namespace MediaBrowser.Controller.Net
  9. {
  10. public interface IWebSocketConnection : IDisposable
  11. {
  12. /// <summary>
  13. /// Occurs when [closed].
  14. /// </summary>
  15. event EventHandler<EventArgs> Closed;
  16. /// <summary>
  17. /// Gets the id.
  18. /// </summary>
  19. /// <value>The id.</value>
  20. Guid Id { get; }
  21. /// <summary>
  22. /// Gets the last activity date.
  23. /// </summary>
  24. /// <value>The last activity date.</value>
  25. DateTime LastActivityDate { get; }
  26. /// <summary>
  27. /// Gets or sets the URL.
  28. /// </summary>
  29. /// <value>The URL.</value>
  30. string Url { get; set; }
  31. /// <summary>
  32. /// Gets or sets the query string.
  33. /// </summary>
  34. /// <value>The query string.</value>
  35. IQueryCollection QueryString { get; set; }
  36. /// <summary>
  37. /// Gets or sets the receive action.
  38. /// </summary>
  39. /// <value>The receive action.</value>
  40. Func<WebSocketMessageInfo, Task> OnReceive { get; set; }
  41. /// <summary>
  42. /// Gets the state.
  43. /// </summary>
  44. /// <value>The state.</value>
  45. WebSocketState State { get; }
  46. /// <summary>
  47. /// Gets the remote end point.
  48. /// </summary>
  49. /// <value>The remote end point.</value>
  50. string RemoteEndPoint { get; }
  51. /// <summary>
  52. /// Sends a message asynchronously.
  53. /// </summary>
  54. /// <typeparam name="T"></typeparam>
  55. /// <param name="message">The message.</param>
  56. /// <param name="cancellationToken">The cancellation token.</param>
  57. /// <returns>Task.</returns>
  58. /// <exception cref="ArgumentNullException">message</exception>
  59. Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
  60. /// <summary>
  61. /// Sends a message asynchronously.
  62. /// </summary>
  63. /// <param name="buffer">The buffer.</param>
  64. /// <param name="cancellationToken">The cancellation token.</param>
  65. /// <returns>Task.</returns>
  66. Task SendAsync(byte[] buffer, CancellationToken cancellationToken);
  67. /// <summary>
  68. /// Sends a message asynchronously.
  69. /// </summary>
  70. /// <param name="text">The text.</param>
  71. /// <param name="cancellationToken">The cancellation token.</param>
  72. /// <returns>Task.</returns>
  73. /// <exception cref="ArgumentNullException">buffer</exception>
  74. Task SendAsync(string text, CancellationToken cancellationToken);
  75. }
  76. }