2013-05-09 10:38:02 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2015-03-09 12:40:03 -07:00
|
|
|
|
using MediaBrowser.Controller.Security;
|
2014-04-15 19:17:48 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-08-10 15:13:17 -07:00
|
|
|
|
using MediaBrowser.Model.Events;
|
2013-09-24 08:42:30 -07:00
|
|
|
|
using MediaBrowser.Model.Session;
|
2014-07-02 11:34:08 -07:00
|
|
|
|
using MediaBrowser.Model.Users;
|
2013-05-09 10:38:02 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-09-24 08:42:30 -07:00
|
|
|
|
using System.Threading;
|
2013-05-09 10:38:02 -07:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Session
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interface ISessionManager
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface ISessionManager
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [playback start].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<PlaybackProgressEventArgs> PlaybackStart;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [playback progress].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<PlaybackProgressEventArgs> PlaybackProgress;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [playback stopped].
|
|
|
|
|
/// </summary>
|
2013-12-30 10:18:18 -07:00
|
|
|
|
event EventHandler<PlaybackStopEventArgs> PlaybackStopped;
|
2013-05-09 10:38:02 -07:00
|
|
|
|
|
2014-04-06 10:53:23 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [session started].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<SessionEventArgs> SessionStarted;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [session ended].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<SessionEventArgs> SessionEnded;
|
2014-05-13 17:46:45 -07:00
|
|
|
|
|
|
|
|
|
event EventHandler<SessionEventArgs> SessionActivity;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [capabilities changed].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<SessionEventArgs> CapabilitiesChanged;
|
2014-08-10 15:13:17 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [authentication failed].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<GenericEventArgs<AuthenticationRequest>> AuthenticationFailed;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [authentication succeeded].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<GenericEventArgs<AuthenticationRequest>> AuthenticationSucceeded;
|
2014-04-06 10:53:23 -07:00
|
|
|
|
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// <summary>
|
2013-05-10 05:18:07 -07:00
|
|
|
|
/// Gets the sessions.
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// </summary>
|
2013-05-10 05:18:07 -07:00
|
|
|
|
/// <value>The sessions.</value>
|
|
|
|
|
IEnumerable<SessionInfo> Sessions { get; }
|
2013-05-09 10:38:02 -07:00
|
|
|
|
|
2013-12-25 07:39:46 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the parts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionFactories">The session factories.</param>
|
|
|
|
|
void AddParts(IEnumerable<ISessionControllerFactory> sessionFactories);
|
|
|
|
|
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logs the user activity.
|
|
|
|
|
/// </summary>
|
2015-03-14 18:42:09 -07:00
|
|
|
|
/// <param name="appName">Type of the client.</param>
|
2013-07-09 09:11:16 -07:00
|
|
|
|
/// <param name="appVersion">The app version.</param>
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// <param name="deviceId">The device id.</param>
|
|
|
|
|
/// <param name="deviceName">Name of the device.</param>
|
2013-12-25 07:39:46 -07:00
|
|
|
|
/// <param name="remoteEndPoint">The remote end point.</param>
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException">user</exception>
|
2015-03-14 18:42:09 -07:00
|
|
|
|
Task<SessionInfo> LogSessionActivity(string appName, string appVersion, string deviceId, string deviceName, string remoteEndPoint, User user);
|
2013-05-09 10:38:02 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to report that playback has started for an item
|
|
|
|
|
/// </summary>
|
2013-09-24 08:08:51 -07:00
|
|
|
|
/// <param name="info">The info.</param>
|
2013-07-09 09:11:16 -07:00
|
|
|
|
/// <returns>Task.</returns>
|
2014-04-15 19:17:48 -07:00
|
|
|
|
Task OnPlaybackStart(PlaybackStartInfo info);
|
2013-05-09 10:38:02 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to report playback progress for an item
|
|
|
|
|
/// </summary>
|
2013-09-30 08:05:07 -07:00
|
|
|
|
/// <param name="info">The info.</param>
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException"></exception>
|
2013-09-30 08:05:07 -07:00
|
|
|
|
Task OnPlaybackProgress(PlaybackProgressInfo info);
|
2013-05-09 10:38:02 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to report that playback has ended for an item
|
|
|
|
|
/// </summary>
|
2013-09-30 08:05:07 -07:00
|
|
|
|
/// <param name="info">The info.</param>
|
2013-05-09 10:38:02 -07:00
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException"></exception>
|
2013-09-30 08:05:07 -07:00
|
|
|
|
Task OnPlaybackStopped(PlaybackStopInfo info);
|
2013-09-24 08:42:30 -07:00
|
|
|
|
|
2014-03-09 19:33:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports the session ended.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2014-05-28 08:51:42 -07:00
|
|
|
|
void ReportSessionEnded(string sessionId);
|
2014-03-09 19:33:19 -07:00
|
|
|
|
|
2014-04-06 10:53:23 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the session info dto.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="session">The session.</param>
|
|
|
|
|
/// <returns>SessionInfoDto.</returns>
|
|
|
|
|
SessionInfoDto GetSessionInfoDto(SessionInfo session);
|
|
|
|
|
|
2013-09-24 08:42:30 -07:00
|
|
|
|
/// <summary>
|
2014-03-31 14:04:22 -07:00
|
|
|
|
/// Sends the general command.
|
2013-09-24 08:42:30 -07:00
|
|
|
|
/// </summary>
|
2014-03-16 09:15:10 -07:00
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
2014-03-31 14:04:22 -07:00
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
2013-09-24 08:42:30 -07:00
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2014-04-15 19:17:48 -07:00
|
|
|
|
Task SendGeneralCommand(string controllingSessionId, string sessionId, GeneralCommand command, CancellationToken cancellationToken);
|
2014-03-31 14:04:22 -07:00
|
|
|
|
|
2013-09-24 12:54:42 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the message command.
|
|
|
|
|
/// </summary>
|
2014-03-16 09:15:10 -07:00
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
2013-09-24 12:54:42 -07:00
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2014-04-15 19:17:48 -07:00
|
|
|
|
Task SendMessageCommand(string controllingSessionId, string sessionId, MessageCommand command, CancellationToken cancellationToken);
|
2013-09-24 12:54:42 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the play command.
|
|
|
|
|
/// </summary>
|
2014-03-16 09:15:10 -07:00
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
2013-09-24 12:54:42 -07:00
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2014-04-15 19:17:48 -07:00
|
|
|
|
Task SendPlayCommand(string controllingSessionId, string sessionId, PlayRequest command, CancellationToken cancellationToken);
|
2013-09-24 12:54:42 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the browse command.
|
|
|
|
|
/// </summary>
|
2014-03-16 09:15:10 -07:00
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
2013-09-24 12:54:42 -07:00
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2014-04-15 19:17:48 -07:00
|
|
|
|
Task SendBrowseCommand(string controllingSessionId, string sessionId, BrowseRequest command, CancellationToken cancellationToken);
|
2013-09-24 12:54:42 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the playstate command.
|
|
|
|
|
/// </summary>
|
2014-03-16 09:15:10 -07:00
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
2013-09-24 12:54:42 -07:00
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2014-04-15 19:17:48 -07:00
|
|
|
|
Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken);
|
2013-10-02 18:22:50 -07:00
|
|
|
|
|
2016-08-18 18:00:04 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the message to admin sessions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <param name="data">The data.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task SendMessageToAdminSessions<T>(string name, T data, CancellationToken cancellationToken);
|
|
|
|
|
|
2015-01-12 20:46:44 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the message to user sessions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <returns>Task.</returns>
|
2016-08-20 11:43:13 -07:00
|
|
|
|
Task SendMessageToUserSessions<T>(List<string> userIds, string name, T data, CancellationToken cancellationToken);
|
2015-01-27 21:04:26 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the message to user device sessions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <param name="data">The data.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task SendMessageToUserDeviceSessions<T>(string deviceId, string name, T data,
|
|
|
|
|
CancellationToken cancellationToken);
|
2015-01-12 20:46:44 -07:00
|
|
|
|
|
2013-10-02 18:22:50 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the restart required message.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2013-10-03 11:02:23 -07:00
|
|
|
|
Task SendRestartRequiredNotification(CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the server shutdown notification.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task SendServerShutdownNotification(CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the server restart notification.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task SendServerRestartNotification(CancellationToken cancellationToken);
|
2014-01-03 19:35:41 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the additional user.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
|
/// <param name="userId">The user identifier.</param>
|
2015-05-29 16:51:33 -07:00
|
|
|
|
void AddAdditionalUser(string sessionId, string userId);
|
2014-01-03 19:35:41 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes the additional user.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
|
/// <param name="userId">The user identifier.</param>
|
2015-05-29 16:51:33 -07:00
|
|
|
|
void RemoveAdditionalUser(string sessionId, string userId);
|
2014-01-11 16:07:56 -07:00
|
|
|
|
|
2014-04-15 19:17:48 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports the now viewing item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
|
/// <param name="itemId">The item identifier.</param>
|
2014-04-30 20:24:55 -07:00
|
|
|
|
void ReportNowViewingItem(string sessionId, string itemId);
|
2014-04-15 19:17:48 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports the now viewing item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2014-04-30 20:24:55 -07:00
|
|
|
|
void ReportNowViewingItem(string sessionId, BaseItemInfo item);
|
2014-07-02 11:34:08 -07:00
|
|
|
|
|
2014-01-11 16:07:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Authenticates the new session.
|
|
|
|
|
/// </summary>
|
2014-08-10 15:13:17 -07:00
|
|
|
|
/// <param name="request">The request.</param>
|
2014-01-11 16:07:56 -07:00
|
|
|
|
/// <returns>Task{SessionInfo}.</returns>
|
2014-11-08 20:18:14 -07:00
|
|
|
|
Task<AuthenticationResult> AuthenticateNewSession(AuthenticationRequest request);
|
2014-03-20 20:31:40 -07:00
|
|
|
|
|
2016-02-20 23:25:25 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates the new session.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>Task<AuthenticationResult>.</returns>
|
|
|
|
|
Task<AuthenticationResult> CreateNewSession(AuthenticationRequest request);
|
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports the capabilities.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
|
/// <param name="capabilities">The capabilities.</param>
|
2014-10-11 13:38:13 -07:00
|
|
|
|
void ReportCapabilities(string sessionId, ClientCapabilities capabilities);
|
2014-06-05 17:39:02 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports the transcoding information.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
|
/// <param name="info">The information.</param>
|
|
|
|
|
void ReportTranscodingInfo(string deviceId, TranscodingInfo info);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clears the transcoding information.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
|
void ClearTranscodingInfo(string deviceId);
|
2014-06-25 08:12:39 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the session.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
|
/// <param name="client">The client.</param>
|
|
|
|
|
/// <param name="version">The version.</param>
|
|
|
|
|
/// <returns>SessionInfo.</returns>
|
|
|
|
|
SessionInfo GetSession(string deviceId, string client, string version);
|
2014-07-02 11:34:08 -07:00
|
|
|
|
|
2015-03-08 12:48:30 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the session by authentication token.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="token">The token.</param>
|
2015-03-12 18:55:22 -07:00
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
2015-03-09 12:40:03 -07:00
|
|
|
|
/// <param name="remoteEndpoint">The remote endpoint.</param>
|
2015-03-08 12:48:30 -07:00
|
|
|
|
/// <returns>SessionInfo.</returns>
|
2015-03-12 18:55:22 -07:00
|
|
|
|
Task<SessionInfo> GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint);
|
2015-03-09 12:40:03 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the session by authentication token.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">The information.</param>
|
2015-03-12 18:55:22 -07:00
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
2015-03-09 12:40:03 -07:00
|
|
|
|
/// <param name="remoteEndpoint">The remote endpoint.</param>
|
|
|
|
|
/// <param name="appVersion">The application version.</param>
|
|
|
|
|
/// <returns>Task<SessionInfo>.</returns>
|
2015-03-12 18:55:22 -07:00
|
|
|
|
Task<SessionInfo> GetSessionByAuthenticationToken(AuthenticationInfo info, string deviceId, string remoteEndpoint, string appVersion);
|
2015-03-08 12:48:30 -07:00
|
|
|
|
|
2014-07-07 18:41:03 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logouts the specified access token.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="accessToken">The access token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task Logout(string accessToken);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Revokes the user tokens.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Task.</returns>
|
2016-06-05 13:39:37 -07:00
|
|
|
|
Task RevokeUserTokens(string userId, string currentAccessToken);
|
2014-07-07 18:41:03 -07:00
|
|
|
|
|
2014-07-11 19:31:08 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Revokes the token.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The identifier.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task RevokeToken(string id);
|
2013-05-09 10:38:02 -07:00
|
|
|
|
}
|
|
|
|
|
}
|