IWebSocketConnection.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using MediaBrowser.Model.Net;
  2. using System;
  3. using System.Collections.Specialized;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Controller.Net
  7. {
  8. public interface IWebSocketConnection : IDisposable
  9. {
  10. /// <summary>
  11. /// Occurs when [closed].
  12. /// </summary>
  13. event EventHandler<EventArgs> Closed;
  14. /// <summary>
  15. /// Gets the id.
  16. /// </summary>
  17. /// <value>The id.</value>
  18. Guid Id { get; }
  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 URL.
  26. /// </summary>
  27. /// <value>The URL.</value>
  28. string Url { get; set; }
  29. /// <summary>
  30. /// Gets or sets the query string.
  31. /// </summary>
  32. /// <value>The query string.</value>
  33. NameValueCollection QueryString { get; set; }
  34. /// <summary>
  35. /// Gets or sets the receive action.
  36. /// </summary>
  37. /// <value>The receive action.</value>
  38. Action<WebSocketMessageInfo> 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. string 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="System.ArgumentNullException">message</exception>
  57. Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
  58. /// <summary>
  59. /// Sends a message asynchronously.
  60. /// </summary>
  61. /// <param name="buffer">The buffer.</param>
  62. /// <param name="cancellationToken">The cancellation token.</param>
  63. /// <returns>Task.</returns>
  64. Task SendAsync(byte[] buffer, CancellationToken cancellationToken);
  65. /// <summary>
  66. /// Sends a message asynchronously.
  67. /// </summary>
  68. /// <param name="text">The text.</param>
  69. /// <param name="cancellationToken">The cancellation token.</param>
  70. /// <returns>Task.</returns>
  71. /// <exception cref="System.ArgumentNullException">buffer</exception>
  72. Task SendAsync(string text, CancellationToken cancellationToken);
  73. }
  74. }