SessionInfo.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using MediaBrowser.Common.Net;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Model.Net;
  4. using System;
  5. namespace MediaBrowser.Controller.Session
  6. {
  7. /// <summary>
  8. /// Class SessionInfo
  9. /// </summary>
  10. public class SessionInfo
  11. {
  12. /// <summary>
  13. /// Gets or sets the id.
  14. /// </summary>
  15. /// <value>The id.</value>
  16. public Guid Id { get; set; }
  17. /// <summary>
  18. /// Gets or sets the user id.
  19. /// </summary>
  20. /// <value>The user id.</value>
  21. public Guid? UserId { get; set; }
  22. /// <summary>
  23. /// Gets or sets the type of the client.
  24. /// </summary>
  25. /// <value>The type of the client.</value>
  26. public string Client { get; set; }
  27. /// <summary>
  28. /// Gets or sets the last activity date.
  29. /// </summary>
  30. /// <value>The last activity date.</value>
  31. public DateTime LastActivityDate { get; set; }
  32. /// <summary>
  33. /// Gets or sets the name of the device.
  34. /// </summary>
  35. /// <value>The name of the device.</value>
  36. public string DeviceName { get; set; }
  37. /// <summary>
  38. /// Gets or sets the now viewing context.
  39. /// </summary>
  40. /// <value>The now viewing context.</value>
  41. public string NowViewingContext { get; set; }
  42. /// <summary>
  43. /// Gets or sets the type of the now viewing item.
  44. /// </summary>
  45. /// <value>The type of the now viewing item.</value>
  46. public string NowViewingItemType { get; set; }
  47. /// <summary>
  48. /// Gets or sets the now viewing item identifier.
  49. /// </summary>
  50. /// <value>The now viewing item identifier.</value>
  51. public string NowViewingItemIdentifier { get; set; }
  52. /// <summary>
  53. /// Gets or sets the now playing item.
  54. /// </summary>
  55. /// <value>The now playing item.</value>
  56. public BaseItem NowPlayingItem { get; set; }
  57. /// <summary>
  58. /// Gets or sets the now playing position ticks.
  59. /// </summary>
  60. /// <value>The now playing position ticks.</value>
  61. public long? NowPlayingPositionTicks { get; set; }
  62. /// <summary>
  63. /// Gets or sets a value indicating whether this instance is paused.
  64. /// </summary>
  65. /// <value><c>true</c> if this instance is paused; otherwise, <c>false</c>.</value>
  66. public bool? IsPaused { get; set; }
  67. /// <summary>
  68. /// Gets or sets the device id.
  69. /// </summary>
  70. /// <value>The device id.</value>
  71. public string DeviceId { get; set; }
  72. /// <summary>
  73. /// Gets or sets the web socket.
  74. /// </summary>
  75. /// <value>The web socket.</value>
  76. public IWebSocketConnection WebSocket { get; set; }
  77. /// <summary>
  78. /// Gets a value indicating whether this instance is active.
  79. /// </summary>
  80. /// <value><c>true</c> if this instance is active; otherwise, <c>false</c>.</value>
  81. public bool IsActive
  82. {
  83. get
  84. {
  85. if (WebSocket != null)
  86. {
  87. return WebSocket.State == WebSocketState.Open;
  88. }
  89. return (DateTime.UtcNow - LastActivityDate).TotalMinutes <= 5;
  90. }
  91. }
  92. /// <summary>
  93. /// Gets a value indicating whether [supports remote control].
  94. /// </summary>
  95. /// <value><c>true</c> if [supports remote control]; otherwise, <c>false</c>.</value>
  96. public bool SupportsRemoteControl
  97. {
  98. get
  99. {
  100. return WebSocket != null && WebSocket.State == WebSocketState.Open;
  101. }
  102. }
  103. }
  104. }