SessionInfo.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using MediaBrowser.Common.Net;
  4. using MediaBrowser.Controller.Entities;
  5. using MediaBrowser.Model.Net;
  6. using System;
  7. namespace MediaBrowser.Controller.Session
  8. {
  9. /// <summary>
  10. /// Class SessionInfo
  11. /// </summary>
  12. public class SessionInfo
  13. {
  14. public SessionInfo()
  15. {
  16. WebSockets = new List<IWebSocketConnection>();
  17. QueueableMediaTypes = new List<string>();
  18. }
  19. /// <summary>
  20. /// Gets or sets a value indicating whether this instance can seek.
  21. /// </summary>
  22. /// <value><c>true</c> if this instance can seek; otherwise, <c>false</c>.</value>
  23. public bool CanSeek { get; set; }
  24. /// <summary>
  25. /// Gets or sets the queueable media types.
  26. /// </summary>
  27. /// <value>The queueable media types.</value>
  28. public List<string> QueueableMediaTypes { get; set; }
  29. /// <summary>
  30. /// Gets or sets the id.
  31. /// </summary>
  32. /// <value>The id.</value>
  33. public Guid Id { get; set; }
  34. /// <summary>
  35. /// Gets or sets the user id.
  36. /// </summary>
  37. /// <value>The user id.</value>
  38. public User User { get; set; }
  39. /// <summary>
  40. /// Gets or sets the type of the client.
  41. /// </summary>
  42. /// <value>The type of the client.</value>
  43. public string Client { get; set; }
  44. /// <summary>
  45. /// Gets or sets the last activity date.
  46. /// </summary>
  47. /// <value>The last activity date.</value>
  48. public DateTime LastActivityDate { get; set; }
  49. /// <summary>
  50. /// Gets or sets the name of the device.
  51. /// </summary>
  52. /// <value>The name of the device.</value>
  53. public string DeviceName { get; set; }
  54. /// <summary>
  55. /// Gets or sets the now viewing context.
  56. /// </summary>
  57. /// <value>The now viewing context.</value>
  58. public string NowViewingContext { get; set; }
  59. /// <summary>
  60. /// Gets or sets the type of the now viewing item.
  61. /// </summary>
  62. /// <value>The type of the now viewing item.</value>
  63. public string NowViewingItemType { get; set; }
  64. /// <summary>
  65. /// Gets or sets the now viewing item identifier.
  66. /// </summary>
  67. /// <value>The now viewing item identifier.</value>
  68. public string NowViewingItemId { get; set; }
  69. /// <summary>
  70. /// Gets or sets the name of the now viewing item.
  71. /// </summary>
  72. /// <value>The name of the now viewing item.</value>
  73. public string NowViewingItemName { get; set; }
  74. /// <summary>
  75. /// Gets or sets the now playing item.
  76. /// </summary>
  77. /// <value>The now playing item.</value>
  78. public BaseItem NowPlayingItem { get; set; }
  79. /// <summary>
  80. /// Gets or sets the now playing position ticks.
  81. /// </summary>
  82. /// <value>The now playing position ticks.</value>
  83. public long? NowPlayingPositionTicks { get; set; }
  84. /// <summary>
  85. /// Gets or sets a value indicating whether this instance is paused.
  86. /// </summary>
  87. /// <value><c>true</c> if this instance is paused; otherwise, <c>false</c>.</value>
  88. public bool IsPaused { get; set; }
  89. /// <summary>
  90. /// Gets or sets a value indicating whether this instance is muted.
  91. /// </summary>
  92. /// <value><c>true</c> if this instance is muted; otherwise, <c>false</c>.</value>
  93. public bool IsMuted { get; set; }
  94. /// <summary>
  95. /// Gets or sets the device id.
  96. /// </summary>
  97. /// <value>The device id.</value>
  98. public string DeviceId { get; set; }
  99. /// <summary>
  100. /// Gets or sets the web socket.
  101. /// </summary>
  102. /// <value>The web socket.</value>
  103. public List<IWebSocketConnection> WebSockets { get; set; }
  104. /// <summary>
  105. /// Gets or sets the application version.
  106. /// </summary>
  107. /// <value>The application version.</value>
  108. public string ApplicationVersion { get; set; }
  109. /// <summary>
  110. /// Gets a value indicating whether this instance is active.
  111. /// </summary>
  112. /// <value><c>true</c> if this instance is active; otherwise, <c>false</c>.</value>
  113. public bool IsActive
  114. {
  115. get
  116. {
  117. if (WebSockets.Count > 0)
  118. {
  119. return WebSockets.Any(i => i.State == WebSocketState.Open);
  120. }
  121. return (DateTime.UtcNow - LastActivityDate).TotalMinutes <= 10;
  122. }
  123. }
  124. /// <summary>
  125. /// Gets a value indicating whether [supports remote control].
  126. /// </summary>
  127. /// <value><c>true</c> if [supports remote control]; otherwise, <c>false</c>.</value>
  128. public bool SupportsRemoteControl
  129. {
  130. get
  131. {
  132. return WebSockets.Any(i => i.State == WebSocketState.Open);
  133. }
  134. }
  135. }
  136. }