IGroupState.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using System.Threading;
  2. using MediaBrowser.Controller.Session;
  3. using MediaBrowser.Model.SyncPlay;
  4. namespace MediaBrowser.Controller.SyncPlay
  5. {
  6. /// <summary>
  7. /// Interface IGroupState.
  8. /// </summary>
  9. public interface IGroupState
  10. {
  11. /// <summary>
  12. /// Gets the group state type.
  13. /// </summary>
  14. /// <value>The group state type.</value>
  15. GroupStateType Type { get; }
  16. /// <summary>
  17. /// Handles a session that joined the group.
  18. /// </summary>
  19. /// <param name="context">The context of the state.</param>
  20. /// <param name="prevState">The previous state.</param>
  21. /// <param name="session">The session.</param>
  22. /// <param name="cancellationToken">The cancellation token.</param>
  23. void SessionJoined(IGroupStateContext context, GroupStateType prevState, SessionInfo session, CancellationToken cancellationToken);
  24. /// <summary>
  25. /// Handles a session that is leaving the group.
  26. /// </summary>
  27. /// <param name="context">The context of the state.</param>
  28. /// <param name="prevState">The previous state.</param>
  29. /// <param name="session">The session.</param>
  30. /// <param name="cancellationToken">The cancellation token.</param>
  31. void SessionLeaving(IGroupStateContext context, GroupStateType prevState, SessionInfo session, CancellationToken cancellationToken);
  32. /// <summary>
  33. /// Generic handle. Context's state can change.
  34. /// </summary>
  35. /// <param name="context">The context of the state.</param>
  36. /// <param name="prevState">The previous state.</param>
  37. /// <param name="request">The generic action.</param>
  38. /// <param name="session">The session.</param>
  39. /// <param name="cancellationToken">The cancellation token.</param>
  40. void HandleRequest(IGroupStateContext context, GroupStateType prevState, IGroupPlaybackRequest request, SessionInfo session, CancellationToken cancellationToken);
  41. /// <summary>
  42. /// Handles a play action requested by a session. Context's state can change.
  43. /// </summary>
  44. /// <param name="context">The context of the state.</param>
  45. /// <param name="prevState">The previous state.</param>
  46. /// <param name="request">The play action.</param>
  47. /// <param name="session">The session.</param>
  48. /// <param name="cancellationToken">The cancellation token.</param>
  49. void HandleRequest(IGroupStateContext context, GroupStateType prevState, PlayGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  50. /// <summary>
  51. /// Handles a playlist-item change requested by a session. Context's state can change.
  52. /// </summary>
  53. /// <param name="context">The context of the state.</param>
  54. /// <param name="prevState">The previous state.</param>
  55. /// <param name="request">The playlist-item change action.</param>
  56. /// <param name="session">The session.</param>
  57. /// <param name="cancellationToken">The cancellation token.</param>
  58. void HandleRequest(IGroupStateContext context, GroupStateType prevState, SetPlaylistItemGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  59. /// <summary>
  60. /// Handles a remove-items change requested by a session. Context's state can change.
  61. /// </summary>
  62. /// <param name="context">The context of the state.</param>
  63. /// <param name="prevState">The previous state.</param>
  64. /// <param name="request">The remove-items change action.</param>
  65. /// <param name="session">The session.</param>
  66. /// <param name="cancellationToken">The cancellation token.</param>
  67. void HandleRequest(IGroupStateContext context, GroupStateType prevState, RemoveFromPlaylistGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  68. /// <summary>
  69. /// Handles a move-item change requested by a session. Context's state should not change.
  70. /// </summary>
  71. /// <param name="context">The context of the state.</param>
  72. /// <param name="prevState">The previous state.</param>
  73. /// <param name="request">The move-item change action.</param>
  74. /// <param name="session">The session.</param>
  75. /// <param name="cancellationToken">The cancellation token.</param>
  76. void HandleRequest(IGroupStateContext context, GroupStateType prevState, MovePlaylistItemGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  77. /// <summary>
  78. /// Handles a queue change requested by a session. Context's state should not change.
  79. /// </summary>
  80. /// <param name="context">The context of the state.</param>
  81. /// <param name="prevState">The previous state.</param>
  82. /// <param name="request">The queue action.</param>
  83. /// <param name="session">The session.</param>
  84. /// <param name="cancellationToken">The cancellation token.</param>
  85. void HandleRequest(IGroupStateContext context, GroupStateType prevState, QueueGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  86. /// <summary>
  87. /// Handles an unpause action requested by a session. Context's state can change.
  88. /// </summary>
  89. /// <param name="context">The context of the state.</param>
  90. /// <param name="prevState">The previous state.</param>
  91. /// <param name="request">The unpause action.</param>
  92. /// <param name="session">The session.</param>
  93. /// <param name="cancellationToken">The cancellation token.</param>
  94. void HandleRequest(IGroupStateContext context, GroupStateType prevState, UnpauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  95. /// <summary>
  96. /// Handles a pause action requested by a session. Context's state can change.
  97. /// </summary>
  98. /// <param name="context">The context of the state.</param>
  99. /// <param name="prevState">The previous state.</param>
  100. /// <param name="request">The pause action.</param>
  101. /// <param name="session">The session.</param>
  102. /// <param name="cancellationToken">The cancellation token.</param>
  103. void HandleRequest(IGroupStateContext context, GroupStateType prevState, PauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  104. /// <summary>
  105. /// Handles a stop action requested by a session. Context's state can change.
  106. /// </summary>
  107. /// <param name="context">The context of the state.</param>
  108. /// <param name="prevState">The previous state.</param>
  109. /// <param name="request">The stop action.</param>
  110. /// <param name="session">The session.</param>
  111. /// <param name="cancellationToken">The cancellation token.</param>
  112. void HandleRequest(IGroupStateContext context, GroupStateType prevState, StopGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  113. /// <summary>
  114. /// Handles a seek action requested by a session. Context's state can change.
  115. /// </summary>
  116. /// <param name="context">The context of the state.</param>
  117. /// <param name="prevState">The previous state.</param>
  118. /// <param name="request">The seek action.</param>
  119. /// <param name="session">The session.</param>
  120. /// <param name="cancellationToken">The cancellation token.</param>
  121. void HandleRequest(IGroupStateContext context, GroupStateType prevState, SeekGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  122. /// <summary>
  123. /// Handles a buffering action requested by a session. Context's state can change.
  124. /// </summary>
  125. /// <param name="context">The context of the state.</param>
  126. /// <param name="prevState">The previous state.</param>
  127. /// <param name="request">The buffering action.</param>
  128. /// <param name="session">The session.</param>
  129. /// <param name="cancellationToken">The cancellation token.</param>
  130. void HandleRequest(IGroupStateContext context, GroupStateType prevState, BufferGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  131. /// <summary>
  132. /// Handles a buffering-done action requested by a session. Context's state can change.
  133. /// </summary>
  134. /// <param name="context">The context of the state.</param>
  135. /// <param name="prevState">The previous state.</param>
  136. /// <param name="request">The buffering-done action.</param>
  137. /// <param name="session">The session.</param>
  138. /// <param name="cancellationToken">The cancellation token.</param>
  139. void HandleRequest(IGroupStateContext context, GroupStateType prevState, ReadyGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  140. /// <summary>
  141. /// Handles a next-track action requested by a session. Context's state can change.
  142. /// </summary>
  143. /// <param name="context">The context of the state.</param>
  144. /// <param name="prevState">The previous state.</param>
  145. /// <param name="request">The next-track action.</param>
  146. /// <param name="session">The session.</param>
  147. /// <param name="cancellationToken">The cancellation token.</param>
  148. void HandleRequest(IGroupStateContext context, GroupStateType prevState, NextTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  149. /// <summary>
  150. /// Handles a previous-track action requested by a session. Context's state can change.
  151. /// </summary>
  152. /// <param name="context">The context of the state.</param>
  153. /// <param name="prevState">The previous state.</param>
  154. /// <param name="request">The previous-track action.</param>
  155. /// <param name="session">The session.</param>
  156. /// <param name="cancellationToken">The cancellation token.</param>
  157. void HandleRequest(IGroupStateContext context, GroupStateType prevState, PreviousTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  158. /// <summary>
  159. /// Handles a repeat-mode change requested by a session. Context's state should not change.
  160. /// </summary>
  161. /// <param name="context">The context of the state.</param>
  162. /// <param name="prevState">The previous state.</param>
  163. /// <param name="request">The repeat-mode action.</param>
  164. /// <param name="session">The session.</param>
  165. /// <param name="cancellationToken">The cancellation token.</param>
  166. void HandleRequest(IGroupStateContext context, GroupStateType prevState, SetRepeatModeGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  167. /// <summary>
  168. /// Handles a shuffle-mode change requested by a session. Context's state should not change.
  169. /// </summary>
  170. /// <param name="context">The context of the state.</param>
  171. /// <param name="prevState">The previous state.</param>
  172. /// <param name="request">The shuffle-mode action.</param>
  173. /// <param name="session">The session.</param>
  174. /// <param name="cancellationToken">The cancellation token.</param>
  175. void HandleRequest(IGroupStateContext context, GroupStateType prevState, SetShuffleModeGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  176. /// <summary>
  177. /// Updates ping of a session. Context's state should not change.
  178. /// </summary>
  179. /// <param name="context">The context of the state.</param>
  180. /// <param name="prevState">The previous state.</param>
  181. /// <param name="request">The buffering-done action.</param>
  182. /// <param name="session">The session.</param>
  183. /// <param name="cancellationToken">The cancellation token.</param>
  184. void HandleRequest(IGroupStateContext context, GroupStateType prevState, PingGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  185. /// <summary>
  186. /// Updates whether the session should be considered during group wait. Context's state should not change.
  187. /// </summary>
  188. /// <param name="context">The context of the state.</param>
  189. /// <param name="prevState">The previous state.</param>
  190. /// <param name="request">The ignore-wait action.</param>
  191. /// <param name="session">The session.</param>
  192. /// <param name="cancellationToken">The cancellation token.</param>
  193. void HandleRequest(IGroupStateContext context, GroupStateType prevState, IgnoreWaitGroupRequest request, SessionInfo session, CancellationToken cancellationToken);
  194. }
  195. }